package cn.fl.customer.controller;

import cmm.comm.facade.framework.api.ISysDictionaryApiService;
import cmm.comm.facade.framework.condition.SysStdRegionQueryCondition;
import cmm.comm.facade.framework.dto.SysDictionaryDTO;
import cmm.mid.core.framework.dto.BaseParamDTO;
import cmm.mid.core.framework.page.DataResultVO;
import cmm.mid.core.framework.page.KeyValueVO;
import cmm.mid.core.framework.page.ListPageVO;
import cmm.mid.core.framework.page.Pager;
import cmm.web.core.framework.controller.BaseController;
import cn.cmm.base.framework.constant.BaseConstant;
import cn.cmm.base.framework.constant.BaseExceptionConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.*;
import cn.cmm.cache.framework.utils.PropertiesCacheUtils;
import cn.fl.customer.service.ICstBscInfoService;
import cn.fl.customer.service.ICstCorpTeamService;
import cn.fl.customer.transform.CstBscInfoVOTransform;
import cn.fl.customer.vo.*;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.framework.constant.DictionaryConstant;
import cn.fl.mfr.web.service.IMfrInfoModService;
import cn.fl.mfr.web.vo.MfrInfoModDtlVO;
import cn.fl.mfr.web.vo.MfrInfoModVO;
import cn.fl.product.service.IMfrInfoService;
import cn.fl.project.service.IPrjBscInfoService;
import cn.fl.ref.fribaseinfo.service.IFriBaseInfoService;
import cn.fl.ref.fribaseinfo.utils.FundRasInsNmChangeUtil;
import cn.fl.ref.fribaseinfo.vo.FriBaseInfoVO;
import cn.fl.risk.condition.RskCstSignLogQueryCondition;
import cn.fl.risk.constant.RiskCstSignLogConstant;
import cn.fl.risk.service.IRskCstSignLogService;
import cn.fl.risk.vo.RskCstSignLogVO;
import cn.fl.system.constant.SysLogConstant;
import cn.fl.system.service.ISysDictionaryService;
import cn.fl.system.service.ISysStdRegionService;
import cn.fl.system.service.ISysUlFilesRecService;
import cn.fl.system.service.ISysUsrService;
import cn.fl.system.vo.SysStdRegionVO;
import cn.fl.system.vo.SysUsrVO;
import cn.fl.upload.constant.UploadConstant;

import com.alibaba.fastjson.JSON;

import fl.constant.facade.framework.constant.SystemConstant;
import fl.customer.facade.customer.condition.*;
import fl.customer.facade.customer.constant.CustomerConstant;
import fl.customer.facade.customer.constant.FilFinanceConstant;
import fl.customer.facade.customer.dto.CstBscInfoDTO;
import fl.customer.facade.customer.dto.CstNpSocialRlDTO;
import fl.customer.facade.customer.utils.CertUtils;
import fl.flow.facade.flow.api.IFlowApiService;
import fl.flow.facade.flow.condition.SysFlowManageVQueryCondition;
import fl.flow.facade.flow.condition.SysFlowSHQueryCondition;
import fl.flow.facade.flow.constant.FlowConstant;
import fl.flow.facade.flow.dto.FlowStartParamsDTO;
import fl.flow.facade.flow.dto.SysFlowManageVDTO;
import fl.flow.facade.flow.dto.SysFlowSHDTO;
import fl.ref.fribaseinfo.condition.FriBaseInfoQueryCondition;
import fl.riskctrl.facade.cfca.api.IChkMpApiService;
import fl.riskctrl.facade.cfca.condition.CstChkEmtRecQueryCondition;
import fl.riskctrl.facade.riskctrl.dto.DataResultDTO;
import fl.spl.facade.framework.constant.SplSystemConstant;
import fl.spl.facade.framework.enums.CommonOpTypCdEnum;
import fl.spl.facade.framework.enums.SplRelLogBizTypCdNum;
import fl.spl.facade.mfr.api.IMfrInfoModApiService;
import fl.spl.facade.mfr.api.IMfrInfoModDtlApiService;
import fl.spl.facade.mfr.condition.MfrInfoModDtlQC;
import fl.spl.facade.mfr.condition.MfrInfoModQC;
import fl.spl.facade.mfr.constant.MfrInfoConstant;
import fl.spl.facade.mfr.dto.MfrInfoModDTO;
import fl.spl.facade.mfr.dto.MfrInfoModDtlDTO;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import tc.esign.facade.esign.api.ICfcaUsrApiService;
import tc.esign.facade.esign.dto.req.user.ApiMobileRealNameValidateDTO;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.lang.reflect.Field;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Pattern;

/**
 * @Description: 客户基础信息表 控制层
 */
@Controller
@RequestMapping("/customer/cstbscinfo")
public class CstBscInfoController extends BaseController {

	private static final Logger logger = LoggerFactory.getLogger(CstBscInfoController.class);

	/**
	 * CstBscInfo 服务层BEAN
	 */
	@Autowired
	private ICstBscInfoService cstBscInfoService;
	
	@Autowired
	private ICstCorpTeamService cstCorpTeamService;
	
	/**
	 * 项目基础服务
	 */
	@Autowired
	private IPrjBscInfoService prjBscInfoService;
	
	/**
	 * 数据字典服务
	 */
	@Autowired
	private ISysDictionaryService sysDictionaryService;
	
	/**
	 * 附件服务
	 */
	@Autowired
	private ISysUlFilesRecService sysUlFilesRecService;
	
	@Autowired
	private ISysStdRegionService sysStdRegionService;
	/**
	 * 手机三要素核查
	 */
	@Autowired
	private IChkMpApiService chkMpApiService;

	/**
	 * 客户风险标记
	 */
	@Autowired
	private IRskCstSignLogService rskCstSignLogService;
	
	@Autowired
	private IMfrInfoService prdMfrInfoService; //厂商服务
	
	@Autowired
    private IMfrInfoModService mfrInfoModService; //厂商-客户变更服务
	
	@Autowired
	private IMfrInfoModDtlApiService mfrInfoModDtlApiService; //厂商-客户变更明细服务
	
	@Autowired
	private IFlowApiService flowApiService; //流程服务
	
	@Autowired
	private ISysUsrService sysUsrService; //用户服务
	
	@Autowired
	private ISysDictionaryApiService sysDictionaryApiService; //数据字典 API服务
	
	@Autowired
	private ICfcaUsrApiService cfcaUsrApiService; //电子签章用户 API服务
	
	@Autowired
	private IMfrInfoModApiService mfrInfoModApiService ; //厂商&客户变更 API服务

	@Autowired
	private IFriBaseInfoService friBaseInfoService;//融资机构基础信息表

	/**
	 * 到列表页面
	 */
	@RequestMapping(value = "/toListPage.do", method = { RequestMethod.GET })
	public ModelAndView toListPage(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView view = new ModelAndView("customer/cstbscinfo/custCstBscInfoList");
		
		//RpcContext.getContext().setAttachment("index", "index1");
		// 获取查询面板下拉框选项
		
		// 客户状态
		List<KeyValueVO> cststscdlist = this.cstBscInfoService.searchCstStsCdList();
		view.addObject("searchSelectCststscdlist", cststscdlist);
		// 客户类型
		List<KeyValueVO> csttypcdlist = this.cstBscInfoService.searchCstTypCdList();
		view.addObject("searchSelectCsttypcdlist", csttypcdlist);
		// 营业执照
		List<KeyValueVO> businesslicenceList = this.cstBscInfoService.searchBusinessLicenceList();
		view.addObject("searchSelectBusinessLicencelist", businesslicenceList);
		// 事业部
		//List<KeyValueVO> orgList = this.cstBscInfoService.searchBusinessOrgList();
		//view.addObject("orgListList", orgList);
		//客户关系属性
		List<KeyValueVO> cstRlTypCdList = this.cstBscInfoService.searchCstRlTypList();
		view.addObject("cstRlTypCdList", cstRlTypCdList);
		// 证件类型
		List<KeyValueVO> lpCertTypCdList = this.cstBscInfoService.searchCertTypCdList(CustomerConstant.CST_TYP_CD_CORP);
		view.addObject("searchSelectLPCertTypCdList", lpCertTypCdList);
		//证件类型
		List<KeyValueVO> certTypCdList = this.cstBscInfoService.searchCertTypCdListZj(CustomerConstant.CST_TYP_CD_NP,CustomerConstant.CST_TYP_CD_NP);
		view.addObject("searchSelectCertTypCdList", certTypCdList);
		//查询项要有默认值,这里给出默认值到前端页面显示
		view.addObject("currentBuOrgCd", CurrentThreadContext.getCurrentBuOrgCd());
		view.addObject("currentCstRlType", DictionaryConstant.CODE_GRP_CST_RL_TYP_CD_1);
		BaseLogUtils.info(logger, "toListPage", "跳转到客户列表页面", CurrentThreadContext.getCurrentUserName());
		return view;
	}
	
	/**
	 * 到列表页面
	 */
	@RequestMapping(value = "/toListForSearchPage.do", method = { RequestMethod.GET })
	public ModelAndView toListForSearchPage(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView view = new ModelAndView("customer/cstbscinfo/custCstBscInfoForSearchList");
		// 获取查询面板下拉框选项
		
		// 客户状态
		List<KeyValueVO> cststscdlist = this.cstBscInfoService.searchCstStsCdList();
		view.addObject("searchSelectCststscdlist", cststscdlist);
		// 客户类型
		List<KeyValueVO> csttypcdlist = this.cstBscInfoService.searchCstTypCdList();
		view.addObject("searchSelectCsttypcdlist", csttypcdlist);
		// 营业执照
		/*List<KeyValueVO> businesslicenceList = this.cstBscInfoService.searchBusinessLicenceList();
		view.addObject("searchSelectBusinessLicencelist", businesslicenceList);*/
		// 事业部
		List<KeyValueVO> orgList = this.cstBscInfoService.searchBusinessOrgList();
		view.addObject("orgListList", orgList);
		//客户关系属性
		List<KeyValueVO> cstRlTypCdList = this.cstBscInfoService.searchCstRlTypList();
		view.addObject("cstRlTypCdList", cstRlTypCdList);
		// 证件类型
		/*List<KeyValueVO> lpCertTypCdList = this.cstBscInfoService.searchCertTypCdList(CustomerConstant.CST_TYP_CD_CORP);
		view.addObject("searchSelectLPCertTypCdList", lpCertTypCdList);*/
		//查询项要有默认值,这里给出默认值到前端页面显示
		view.addObject("currentBuOrgCd", CurrentThreadContext.getCurrentBuOrgCd());
		view.addObject("currentCstRlType", DictionaryConstant.CODE_GRP_CST_RL_TYP_CD_1);
		BaseLogUtils.info(logger, "toListPage", "跳转到客户列表页面", CurrentThreadContext.getCurrentUserName());
		return view;
	}

	/**
	 * 客户查询（所有）
	 */
	@RequestMapping(value = "/toListAllForSearchPage.do", method = { RequestMethod.GET })
	public ModelAndView toListAllForSearchPage(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView view = new ModelAndView("customer/cstbscinfo/custCstBscInfoAllList");
		// 获取查询面板下拉框选项

		// 客户状态
		List<KeyValueVO> cststscdlist = this.cstBscInfoService.searchCstStsCdList();
		view.addObject("searchSelectCststscdlist", cststscdlist);
		// 客户类型
		List<KeyValueVO> csttypcdlist = this.cstBscInfoService.searchCstTypCdList();
		view.addObject("searchSelectCsttypcdlist", csttypcdlist);
		// 营业执照
		/*List<KeyValueVO> businesslicenceList = this.cstBscInfoService.searchBusinessLicenceList();
		view.addObject("searchSelectBusinessLicencelist", businesslicenceList);*/
		// 事业部
		List<KeyValueVO> orgList = this.cstBscInfoService.searchBusinessOrgList();
		view.addObject("orgListList", orgList);
		//客户关系属性
		List<KeyValueVO> cstRlTypCdList = this.cstBscInfoService.searchCstRlTypList();
		view.addObject("cstRlTypCdList", cstRlTypCdList);
		// 证件类型
		/*List<KeyValueVO> lpCertTypCdList = this.cstBscInfoService.searchCertTypCdList(CustomerConstant.CST_TYP_CD_CORP);
		view.addObject("searchSelectLPCertTypCdList", lpCertTypCdList);*/
		//查询项要有默认值,这里给出默认值到前端页面显示
		view.addObject("currentBuOrgCd", CurrentThreadContext.getCurrentBuOrgCd());
		view.addObject("currentCstRlType", DictionaryConstant.CODE_GRP_CST_RL_TYP_CD_1);
		BaseLogUtils.info(logger, "toListPage", "跳转到客户列表页面", CurrentThreadContext.getCurrentUserName());
		return view;
	}

	/**
	 * 客户客户列表身份证（所有）
	 */
	@RequestMapping(value = "/toListAllForFilesPage.do", method = { RequestMethod.GET })
	public ModelAndView toListAllForFilesPage(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView view = new ModelAndView("customer/cstbscinfo/custCstBscInfoFileList");
		BaseLogUtils.info(logger, "toListPage", "跳转到客户列表身份证上传页面", CurrentThreadContext.getCurrentUserName());
		return view;
	}

	/**
	 * 客户身份证附件
	 */
	@RequestMapping(value = "/toCustCstBscInfoFileDetail.do", method = { RequestMethod.GET })
	public ModelAndView toCustCstBscInfoFileDetail(HttpServletRequest request, HttpServletResponse response) {
        String dataId = request.getParameter("dataId");
		ModelAndView view = new ModelAndView("customer/cstbscinfo/custCstBscInfoFileDetail");
        view.addObject("dataId",dataId);
		BaseLogUtils.info(logger, "toListPage", "客户跳转到列表身份证上传页面", CurrentThreadContext.getCurrentUserName());
		return view;
	}

	/**
	 * 初始化列表(查询所有)
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/initAllList.do", method = { RequestMethod.GET })
	@ResponseBody
	public Object initAllList(HttpServletRequest request, HttpServletResponse response) {
		String currentPage = request.getParameter("page");
		String pageSize = request.getParameter("pagesize");
		// 查询条件
		String cstNm = request.getParameter("cstNm");//客户名称
		String cstTypCd = request.getParameter("cstTypCd");//客户类型
		String certNo = request.getParameter("certNo");//证件号码

		Pager page = new Pager();
		if (StringUtils.isNotEmpty(currentPage)) {
			page.setCurrentPage(Integer.parseInt(currentPage));
		}

		if (StringUtils.isNotEmpty(pageSize)) {
			page.setEveryPage(Integer.parseInt(pageSize));
		}

		CstBscInfoQueryCondition qc = new CstBscInfoQueryCondition();
		Boolean isHasCon = false;

		if (StringUtils.isNotEmpty(cstNm)) {
			qc.setCstNm(cstNm);
			isHasCon = true;
		}

		if (StringUtils.isNotEmpty(cstTypCd)) {
			qc.setCstTypCd(cstTypCd);
			isHasCon = true;
		}

		if (StringUtils.isNotEmpty(certNo)) {
			qc.setCertNo(certNo);
			isHasCon = true;
		}

		qc.setSysCd(CurrentThreadContext.getCurrentSysCd());
		qc.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
		page.setCondition(qc);
        Pager pager = this.cstBscInfoService.searchAllListPage(page);
        List<CstBscInfoVO> list = (List<CstBscInfoVO>) pager.getResultList();
        ListPageVO<CstBscInfoVO> listPage = new ListPageVO<CstBscInfoVO>(list, pager.getTotalCount());
		BaseLogUtils.info(logger, "initList", "初始化列表数据.DATA:" + com.alibaba.fastjson.JSONObject.toJSONString(page), CurrentThreadContext.getCurrentUserName());
		return listPage;
	}
	
	/**
	 * 到企业详细页面
	 */
	@RequestMapping(value = "/toCustCstBacInfoCorpDetailPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toCustCstBacInfoCorpDetailPage(HttpServletRequest request, HttpServletResponse response) {
		String id = request.getParameter("id");
		ModelAndView view = new ModelAndView("customer/cstbscinfo/custCstBacInfoCorpDetail");
		String roleIsEncrypt=this.sysDictionaryService.getRoleisEncrypt();

		CstCorpTeamQueryCondition cstCorpTeamQueryCondition = new CstCorpTeamQueryCondition();
		List<Long> cstIdList = new ArrayList<>();
		cstIdList.add(Long.valueOf(id));
		cstCorpTeamQueryCondition.setCstIdList(cstIdList);
		cstCorpTeamQueryCondition.setSysCd(CurrentThreadContext.getCurrentSysCd());
		List<CstCorpTeamVO> teamMenList = this.cstCorpTeamService.searchList(cstCorpTeamQueryCondition);
		if(CollectionUtils.isNotEmpty(teamMenList) && BaseConstant.IS_YESNO_YES_STR.equals(roleIsEncrypt)){
			for (CstCorpTeamVO vo:teamMenList){
				vo.setCertNo(EncryptUtil.certNoEncrypt(vo.getCertNo()));
				vo.setMp1(EncryptUtil.mobileEncrypt(vo.getMp1()));
			}
		}
		view.addObject("teamMenList", teamMenList);
		// 证件类型(自然人)
		List<KeyValueVO> certTypCdForNpList = this.cstBscInfoService.searchCertTypCdList(CustomerConstant.CST_TYP_CD_NP);
		view.addObject("searchSelectCertTypCdForNpList", certTypCdForNpList);
		List<String> codeGrpCdList = new ArrayList<>();
		codeGrpCdList.add(DictionaryConstant.CODE_GRP_M_TYP_CD);
		Map<String, List<KeyValueVO>> dicMap = this.sysDictionaryService.getMultiKvList(CurrentThreadContext.getFlServiceSysCd(), CurrentThreadContext.getCurrentOrgCd(), codeGrpCdList);
		view.addObject("searchSelectMTypCdList", dicMap.get(DictionaryConstant.CODE_GRP_M_TYP_CD));
		view.addObject("id", id);
		BaseLogUtils.info(logger, "toCustCstBacInfoCorpDetailPage", "跳转到企业详情页面. ID:" + id, CurrentThreadContext.getCurrentUserName());
		return view;
	}
	
	/**
	 * 到自然人详细页面
	 */
	@RequestMapping(value = "/toCustCstBacInfoNpDetailPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toCustCstBacInfoNpDetailPage(HttpServletRequest request, HttpServletResponse response) {
		String id = request.getParameter("id");
		ModelAndView view = new ModelAndView("customer/cstbscinfo/custCstBacInfoNpDetail");
		view.addObject("id", id);
		//加入默认自然人照片
		this.getDefaultUserPic(view, "defaultHeadPic");
		BaseLogUtils.info(logger, "toCustCstBacInfoNpDetailPage", "跳转到自然人详情页面 .ID:" + id, CurrentThreadContext.getCurrentUserName());
		return view;
	}

	/**
	 * 到自然人新增页面
	 */
	@RequestMapping(value = "/toCustCstBacInfoNpAddPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toCustCstBacInfoNpAddPage(HttpServletRequest request, HttpServletResponse response) {
		BaseLogUtils.info(logger, "toCustCstBacInfoNpAddPage", "参数"+this.getRequestParameter(request));
		String id = request.getParameter("id");
		String cstNm = request.getParameter("cstNm");
		String certNo = request.getParameter("certNo");
		String npCertTypCd =request.getParameter("npCertTypCd");
		String mySelfImgUrl = request.getParameter("imgUrl");//客户自己身份证照片地址
		// 直接进入新增页面的Flag
		String toAddFlag = request.getParameter("toAddFlag");
		BaseLogUtils.info(logger, "toCustCstBacInfoNpAddPage", this.getRequestParameter(request));
		ModelAndView view = new ModelAndView("customer/cstbscinfo/custCstBacInfoNpAdd");
		view.addObject("toAddFlag", toAddFlag);
		view.addObject("id", id);
		view.addObject("cstNm", cstNm);
		view.addObject("certNo", certNo);
		view.addObject("npCertTypCd", npCertTypCd);
		view.addObject("mySelfImgUrl", mySelfImgUrl);
		String serverPath = PropertiesCacheUtils.getProperty(UploadConstant.UPLOAD_SERVER_PATH);//根目录
		view.addObject("mySelfImgUrlAll", serverPath+mySelfImgUrl);
		if(StringUtils.isEmpty(mySelfImgUrl)){
			//加入默认自然人照片
			this.getDefaultUserPic(view, "mySelfImgUrlAll");
		}
		//加入默认自然人照片
		this.getDefaultUserPic(view, "myPeiOuImgUrlAll");
		
		try {
			//客户关系属性
			JSONArray cstRlTypCdJA = this.cstBscInfoService.searchCstRlTypArray();
			view.addObject("cstRlTypCdList", cstRlTypCdJA);
			//新增的时候客户关系属性默认值
			view.addObject("currentCstRlTypeForAdd", DictionaryConstant.CODE_GRP_CST_RL_TYP_CD_1);
			// 证件类型
			List<KeyValueVO> npCertTypCdList = this.cstBscInfoService.searchCertTypCdListZj(CustomerConstant.CST_TYP_CD_NP,CustomerConstant.CST_TYP_CD_NP);
			view.addObject("searchSelectNPCertTypCdList", npCertTypCdList);
			List<String> codeGrpCdList = new ArrayList<>();
			codeGrpCdList.add(DictionaryConstant.CODE_GRP_MAR_STS_CD);
			codeGrpCdList.add(DictionaryConstant.CODE_GRP_GENDER_CD);
			codeGrpCdList.add(DictionaryConstant.CODE_GRP_CST_NATION_CD);
			codeGrpCdList.add("CST0065");
			//codeGrpCdList.add(DictionaryConstant.CODE_GRP_CST_OCP_CD);
			//codeGrpCdList.add(DictionaryConstant.CODE_GRP_CST_POS_CD);
			//codeGrpCdList.add(DictionaryConstant.CODE_GRP_CST_TIT_CD);
			codeGrpCdList.add(fl.customer.facade.framework.constant.DictionaryConstant.CODE_GRP_BACK_PAY_TYP_CD);
			codeGrpCdList.add(fl.customer.facade.framework.constant.DictionaryConstant.CODE_GRP_HIGH_DG_CD);
			codeGrpCdList.add(fl.customer.facade.framework.constant.DictionaryConstant.CODE_GRP_EDU_LVL_CD);
			//codeGrpCdList.add(fl.customer.facade.framework.constant.DictionaryConstant.CODE_GRP_ZX_CST_LVL_CD);
			codeGrpCdList.add(fl.customer.facade.framework.constant.DictionaryConstant.CODE_GRP_PRJ_CTRL_CD);
			Map<String, List<KeyValueVO>> dicMap = this.sysDictionaryService.getMultiKvList(CurrentThreadContext.getFlServiceSysCd(), CurrentThreadContext.getCurrentOrgCd(), codeGrpCdList);
			view.addObject("searchSelectMarStsCdList", dicMap.get(DictionaryConstant.CODE_GRP_MAR_STS_CD));// 婚姻状况
			view.addObject("searchSelectGenderCdList", dicMap.get(DictionaryConstant.CODE_GRP_GENDER_CD));// 性别状况
			view.addObject("searchNationCdList", dicMap.get("CST0065"));// 民族
			//view.addObject("searchSelectOcpCdlist", dicMap.get(DictionaryConstant.CODE_GRP_CST_OCP_CD));//职业
			//view.addObject("searchSelectPosCdlist", dicMap.get(DictionaryConstant.CODE_GRP_CST_POS_CD));//职务
			//view.addObject("searchSelectTitCdlist", dicMap.get(DictionaryConstant.CODE_GRP_CST_TIT_CD));//职称
			view.addObject("payTyplist", dicMap.get(fl.customer.facade.framework.constant.DictionaryConstant.CODE_GRP_BACK_PAY_TYP_CD));//还款方式
			view.addObject("highDgCdList", dicMap.get(fl.customer.facade.framework.constant.DictionaryConstant.CODE_GRP_HIGH_DG_CD));//最高学历
			view.addObject("eduLvlCdList", dicMap.get(fl.customer.facade.framework.constant.DictionaryConstant.CODE_GRP_EDU_LVL_CD));//文化程度组值
			//view.addObject("livCndCdList", dicMap.get(fl.customer.facade.framework.constant.DictionaryConstant.CODE_GRP_LIV_CND_CD));//居住状况
			//view.addObject("cstLvlCdList", dicMap.get(fl.customer.facade.framework.constant.DictionaryConstant.CODE_GRP_ZX_CST_LVL_CD));//客户分级
			view.addObject("prjCtrlCdList", dicMap.get(fl.customer.facade.framework.constant.DictionaryConstant.CODE_GRP_PRJ_CTRL_CD));//立项控制
		} catch (Exception e) {
			BaseLogUtils.error(logger, "toCustCstBacInfoNpAddPage", "获取基础信息错误!" , e);
		}
		
		BaseLogUtils.info(logger, "toCustCstBacInfoNpAddPage", "跳转到自然人新增/修改页面. ID:" + id, CurrentThreadContext.getCurrentUserName());
		return view;
	}

	/**
	 * 到法人修改页面
	 */
	@RequestMapping(value = "/toCustCstBacInfoCorpAddPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toCustCstBacInfoCorpAddPage(HttpServletRequest request, HttpServletResponse response) {
		String id = request.getParameter("id");
		String cstNm = request.getParameter("cstNm");
		String certNo = request.getParameter("certNo");
		String certTypCd = request.getParameter("certTypCd");
		String corpLowerNm = request.getParameter("corpLowerNm");//法人代表名称
		String corpLowerCertNo = request.getParameter("corpLowerCertNo");//法人身份证
		String corpForCertTypCd = request.getParameter("corpForCertTypCd");//法人证件类型
		// 直接进入新增页面的Flag
		String toAddFlag = request.getParameter("toAddFlag");
		ModelAndView view = new ModelAndView("customer/cstbscinfo/custCstBacInfoCorpAdd");
		view.addObject("toAddFlag", toAddFlag);
		view.addObject("id", id);
		view.addObject("cstNm", cstNm);
		view.addObject("certNo", certNo);
		view.addObject("certTypCd", certTypCd);
		view.addObject("lowerCstNm", corpLowerNm);
		view.addObject("lowerCertNo", corpLowerCertNo);
		view.addObject("corpForCertTypCd", corpForCertTypCd);
		view.addObject("currentCstRlTypeForAdd", DictionaryConstant.CODE_GRP_CST_RL_TYP_CD_1);//新增的时候客户关系属性默认值
		// 证件类型
		List<KeyValueVO> certTypCdList = this.cstBscInfoService.searchCertTypCdList(CustomerConstant.CST_TYP_CD_CORP);
		view.addObject("searchSelectCertTypCdList", certTypCdList);
		// 证件类型(自然人)
		List<KeyValueVO> certTypCdForNpList = this.cstBscInfoService.searchCertTypCdList(CustomerConstant.CST_TYP_CD_NP);
		view.addObject("searchSelectCertTypCdForNpList", certTypCdForNpList);
		//客户关系属性
		JSONArray cstRlTypCdJA = this.cstBscInfoService.searchCstRlTypArray();
		view.addObject("cstRlTypCdList", cstRlTypCdJA);
		if(StringUtils.isNotBlank(id)){
			//主要团队成员
			CstCorpTeamQueryCondition cstCorpTeamQueryCondition = new CstCorpTeamQueryCondition();
			List<Long> cstIdList = new ArrayList<>();
			cstIdList.add(Long.valueOf(id));
			cstCorpTeamQueryCondition.setCstIdList(cstIdList);
			cstCorpTeamQueryCondition.setSysCd(CurrentThreadContext.getCurrentSysCd());
			List<CstCorpTeamVO> teamMenList = this.cstCorpTeamService.searchList(cstCorpTeamQueryCondition);
			/**
			 * 如果没有财务总监，财务总监，法人代表 补充到集合中
			 */
			List<String> mTypCdList = new ArrayList<>();
			if(CollectionUtils.isNotEmpty(teamMenList)){
				for(CstCorpTeamVO cstCorpTeamVO : teamMenList){
					mTypCdList.add(cstCorpTeamVO.getMTypCd());
				}
			}
			if(!mTypCdList.contains(DictionaryConstant.CODE_GRP_M_TYP_CD_7)){
				CstCorpTeamVO cstCorpTeamVO = new CstCorpTeamVO();
				cstCorpTeamVO.setMTypCd(DictionaryConstant.CODE_GRP_M_TYP_CD_7);
				teamMenList.add(cstCorpTeamVO);
			}
			if(!mTypCdList.contains(DictionaryConstant.CODE_GRP_M_TYP_CD_10)){
				CstCorpTeamVO cstCorpTeamVO = new CstCorpTeamVO();
				cstCorpTeamVO.setMTypCd(DictionaryConstant.CODE_GRP_M_TYP_CD_10);
				teamMenList.add(cstCorpTeamVO);
			}
			view.addObject("teamMenList", teamMenList);
		}
		
		
		try {
			List<String> codeGrpCdList = new ArrayList<>();
			codeGrpCdList.add(DictionaryConstant.CODE_GRP_CORP_TYP_CD);
			codeGrpCdList.add(DictionaryConstant.CODE_GRP_REG_CAP_UNT_CD);
			codeGrpCdList.add(DictionaryConstant.CODE_SYS_YES_NO_CD);
			codeGrpCdList.add(DictionaryConstant.CODE_GRP_M_TYP_CD);
			codeGrpCdList.add(fl.customer.facade.framework.constant.DictionaryConstant.CODE_GRP_BACK_PAY_TYP_CD);
			codeGrpCdList.add(fl.customer.facade.framework.constant.DictionaryConstant.CODE_GRP_PRJ_CTRL_CD);
			Map<String, List<KeyValueVO>> dicMap = this.sysDictionaryService.getMultiKvList(CurrentThreadContext.getFlServiceSysCd(), CurrentThreadContext.getCurrentOrgCd(), codeGrpCdList);
			view.addObject("searchSelectCorpTypCdList", dicMap.get(DictionaryConstant.CODE_GRP_CORP_TYP_CD));//企业性质
			view.addObject("searchSelectRegCapUntCdList", dicMap.get(DictionaryConstant.CODE_GRP_REG_CAP_UNT_CD));//万元 美元
			view.addObject("searchSelectPaidCapUntCdList", dicMap.get(DictionaryConstant.CODE_GRP_REG_CAP_UNT_CD));//万元 美元
			view.addObject("yNList", dicMap.get(DictionaryConstant.CODE_SYS_YES_NO_CD));///是否事业单位
			view.addObject("payTyplist", dicMap.get(fl.customer.facade.framework.constant.DictionaryConstant.CODE_GRP_BACK_PAY_TYP_CD));//还款方式
			view.addObject("prjCtrlCdList", dicMap.get(fl.customer.facade.framework.constant.DictionaryConstant.CODE_GRP_PRJ_CTRL_CD));//立项控制
			view.addObject("searchSelectMTypCdList", dicMap.get(DictionaryConstant.CODE_GRP_M_TYP_CD));
		} catch (Exception e) {
			BaseLogUtils.error(logger, "toCustCstBacInfoCorpAddPage", "获取基础DIC信息错误!", e);
		}
		BaseLogUtils.info(logger, "toCustCstBacInfoCorpAddPage", "跳转到法人新增/修改页面 .ID:" + id, CurrentThreadContext.getCurrentUserName());
		return view;
	}
	
	/**
	 * 到企业备案信息Tab页面
	 */
	@RequestMapping(value = "/toCustCstBacInfoCorpEpRecordPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toCustCstBacInfoCorpEpRecordPage(HttpServletRequest request, HttpServletResponse response) {
		String cstId = request.getParameter("cstId");
		ModelAndView view = new ModelAndView("customer/cstbscinfo/custCstBacInfoCorpEpRecord");
		view.addObject("cstId", cstId);
		BaseLogUtils.info(logger, "toCustCstBacInfoCorpEpRecordPage", "跳转到企业备案页面.cstId:" + cstId, CurrentThreadContext.getCurrentUserName());
		return view;
	}
	
	/**
	 * 到企业备案信息Tab页面
	 */
	@RequestMapping(value = "/toCustCstBacInfoCorpEpRecordDetailPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toCustCstBacInfoCorpEpRecordDetailPage(HttpServletRequest request, HttpServletResponse response) {
		String cstId = request.getParameter("cstId");
		ModelAndView view = new ModelAndView("customer/cstbscinfo/custCstBacInfoCorpEpRecordDetail");
		view.addObject("cstId", cstId);
		BaseLogUtils.info(logger, "toCustCstBacInfoCorpEpRecordDetailPage", "跳转到企业备案详细页面.cstId:" + cstId, CurrentThreadContext.getCurrentUserName());
		return view;
	}
	
	/**
	 * 到资产信息Tab页面
	 */
	@RequestMapping(value = "/toCustCstBacInfoEpAssetPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toCustCstBacInfoEpAssetPage(HttpServletRequest request, HttpServletResponse response) {
		String cstId = request.getParameter("cstId");
		ModelAndView view = new ModelAndView("customer/cstbscinfo/custCstBacInfoEpAsset");
		view.addObject("cstId", cstId);
		BaseLogUtils.info(logger, "toCustCstBacInfoEpAssetPage", "跳转到资产信息页面.cstId:" + cstId, CurrentThreadContext.getCurrentUserName());
		return view;
	}
	/**
	 * 到自然人银行账号信息Tab页面
	 */
	@RequestMapping(value = "/toCustCstBacInfoNpBankAccPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toCustCstBacInfoNpBankAccPage(HttpServletRequest request, HttpServletResponse response) {
		String cstId = request.getParameter("cstId");
		ModelAndView view = new ModelAndView("customer/cstbank/custCstBacInfoNpBankList");
		view.addObject("cstId", cstId);
		try {
			List<String> codeGrpCdList = new ArrayList<>();
			codeGrpCdList.add(DictionaryConstant.CODE_GRP_VALID_STATUS_CD);
			codeGrpCdList.add(DictionaryConstant.CODE_SYS_YES_NO_CD);
			Map<String, List<KeyValueVO>> dicMap = this.sysDictionaryService.getMultiKvList(CurrentThreadContext.getFlServiceSysCd(), CurrentThreadContext.getCurrentOrgCd(), codeGrpCdList);
			view.addObject("validStsList", dicMap.get(DictionaryConstant.CODE_GRP_VALID_STATUS_CD));
			view.addObject("searchSelectYesOrNoList", dicMap.get(DictionaryConstant.CODE_SYS_YES_NO_CD));
		} catch (Exception e) {
			BaseLogUtils.error(logger, "toCustCstBacInfoNpBankAccPage", "获取基础DIC信息错误!", e);
		}
		BaseLogUtils.info(logger, "toCustCstBacInfoNpBankAccPage", "跳转到银行账户列表页面.cstId:" + cstId, CurrentThreadContext.getCurrentUserName());
		return view;
	}
	
	/**
	 * 到法人银行账号信息Tab页面
	 */
	@RequestMapping(value = "/toCustCstBacInfoCorpBankAccPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toCustCstBacInfoCorpBankAccPage(HttpServletRequest request, HttpServletResponse response) {
		String cstId = request.getParameter("cstId");
		ModelAndView view = new ModelAndView("customer/cstbank/custCstBacInfoCorpBankList");
		view.addObject("cstId", cstId);
		try {
			List<String> codeGrpCdList = new ArrayList<>();
			codeGrpCdList.add(DictionaryConstant.CODE_GRP_VALID_STATUS_CD);
			codeGrpCdList.add(DictionaryConstant.CODE_SYS_YES_NO_CD);
			Map<String, List<KeyValueVO>> dicMap = this.sysDictionaryService.getMultiKvList(CurrentThreadContext.getFlServiceSysCd(), CurrentThreadContext.getCurrentOrgCd(), codeGrpCdList);
			view.addObject("validStsList", dicMap.get(DictionaryConstant.CODE_GRP_VALID_STATUS_CD));
			view.addObject("searchSelectYesOrNoList", dicMap.get(DictionaryConstant.CODE_SYS_YES_NO_CD));
		} catch (Exception e) {
			BaseLogUtils.error(logger, "toCustCstBacInfoCorpBankAccPage", "获取基础DIC信息错误!" + e.getMessage());
		}
		BaseLogUtils.info(logger, "toCustCstBacInfoCorpBankAccPage", "跳转到银行账户列表页面.cstId:" + cstId, CurrentThreadContext.getCurrentUserName());
		return view;
	}
	
	/**
	 * 跳转到客户担保方式页面,里面是动态字段
	 */
	@RequestMapping(value = "/toCstGuarDynamicPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toCstGuarDynamicPage(HttpServletRequest request, HttpServletResponse response) {
		String bizCd = request.getParameter("bizCd");//多个值,分隔符为; ,如   1;2;3
		ModelAndView view = new ModelAndView("customer/cstdynamic/cstGuarDynamicPage");
		view.addObject("bizCd", bizCd.replaceAll(";", ","));
		BaseLogUtils.info(logger, "toCstGuarDynamicPage", "跳转到担保方式页面,里面是动态字段.bizCd:" + bizCd, CurrentThreadContext.getCurrentUserName());
		return view;
	}
	
	/**
	 * 跳转到客户担保方式页面,里面是动态字段
	 */
	@RequestMapping(value = "/toCstGuarDetailDynamicPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toCstGuarDetailDynamicPage(HttpServletRequest request, HttpServletResponse response) {
		String bizCd = request.getParameter("bizCd");//多个值,分隔符为; ,如   1;2;3
		ModelAndView view = new ModelAndView("customer/cstdynamic/cstGuarDetailDynamicPage");
		view.addObject("bizCd", bizCd.replaceAll(";", ","));
		BaseLogUtils.info(logger, "toCstGuarDetailDynamicPage", "跳转到担保方式页面,里面是动态显示字段.bizCd:" + bizCd, CurrentThreadContext.getCurrentUserName());
		return view;
	}
	
	
	/**
	 * 跳转到自然人信息页面,里面是动态字段
	 */
	@RequestMapping(value = "/toCstDynamicPageForNp.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toCstDynamicPageForNp(HttpServletRequest request, HttpServletResponse response) {
		String bizCd = request.getParameter("bizCd");//多个值,分隔符为; ,如   1;2;3
		ModelAndView view = new ModelAndView("customer/cstdynamic/cstDynamicPageForNp");
		view.addObject("bizCd", bizCd.replaceAll(";", ","));
		BaseLogUtils.info(logger, "toCstDynamicPageForNp", "跳转到自然人页面,里面是动态字段.bizCd:" + bizCd, CurrentThreadContext.getCurrentUserName());
		return view;
	}
	
	/**
	 * 跳转到自然人信息页面,里面是动态字段
	 */
	@RequestMapping(value = "/toCstDetailDynamicPageForNp.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toCstDetailDynamicPageForNp(HttpServletRequest request, HttpServletResponse response) {
		String bizCd = request.getParameter("bizCd");//多个值,分隔符为; ,如   1;2;3
		ModelAndView view = new ModelAndView("customer/cstdynamic/cstDetailDynamicPageForNp");
		view.addObject("bizCd", bizCd.replaceAll(";", ","));
		BaseLogUtils.info(logger, "toCstDetailDynamicPageForNp", "跳转到自然人页面,里面是动态显示字段.bizCd:" + bizCd, CurrentThreadContext.getCurrentUserName());
		return view;
	}
	
	/**
	 * 跳转到法人信息页面,里面是动态字段
	 */
	@RequestMapping(value = "/toCstGuarDynamicPageForCorp.do", method = { RequestMethod.GET, RequestMethod.POST})
	public ModelAndView toCstGuarDynamicPageForCorp(HttpServletRequest request, HttpServletResponse response) {
		String bizCd = request.getParameter("bizCd");//多个值,分隔符为; ,如   1;2;3
		ModelAndView view = new ModelAndView("customer/cstdynamic/cstGuarDynamicPageForCorp");
		view.addObject("bizCd", bizCd.replaceAll(";", ","));
		BaseLogUtils.info(logger, "toCstGuarDynamicPageForCorp", "跳转到法人页面,里面是动态字段.bizCd:" + bizCd, CurrentThreadContext.getCurrentUserName());
		return view;
	}
	
	/**
	 * 跳转到法人信息页面,里面是动态字段
	 */
	@RequestMapping(value = "/toCstGuarDetailDynamicPageForCorp.do", method = { RequestMethod.GET, RequestMethod.POST})
	public ModelAndView toCstGuarDetailDynamicPageForCorp(HttpServletRequest request, HttpServletResponse response) {
		String bizCd = request.getParameter("bizCd");//多个值,分隔符为; ,如   1;2;3
		ModelAndView view = new ModelAndView("customer/cstdynamic/cstGuarDetailDynamicPageForCorp");
		view.addObject("bizCd", bizCd.replaceAll(";", ","));
		BaseLogUtils.info(logger, "toCstGuarDetailDynamicPageForCorp", "跳转到法人页面,里面是动态显示字段.bizCd:" + bizCd, CurrentThreadContext.getCurrentUserName());
		return view;
	}
	
	/**
	 * 跳转到客户征信页面
	 */
	@RequestMapping(value = "/toCstCreditPage.do", method = { RequestMethod.GET})
	public ModelAndView toCstCreditPage(HttpServletRequest request, HttpServletResponse response) {
		String cstId = request.getParameter("cstId");
		ModelAndView view = new ModelAndView("customer/cstcredit/cstCreditList");
		view.addObject("cstId", cstId);
		BaseLogUtils.info(logger, "toCstCreditPage", "跳转到客户征信cstId:" + cstId, CurrentThreadContext.getCurrentUserName());
		return view;
	}
	/**
	 * 跳转到财务报表页面
	 */
	@RequestMapping(value = "/toFilFinanceDebtPage.do", method = { RequestMethod.GET})
	public ModelAndView toFilFinanceDebtPage(HttpServletRequest request, HttpServletResponse response) {
		String cstId = request.getParameter("cstId");
		ModelAndView view = new ModelAndView();
			CstBscInfoVO vo = new CstBscInfoVO();
			if(StringUtils.isNotEmpty(cstId)){
				vo = this.cstBscInfoService.selectDetailById(Long.valueOf(cstId));
			}
		List<String> codeGrpCdList = new ArrayList<>();
		codeGrpCdList.add(FilFinanceConstant.CST_REPORT_TYPE_CD);//报表类型
		codeGrpCdList.add(FilFinanceConstant.CST_REPORT_SUB_TYPE_CD);//报表类型细分
		Map<String, List<KeyValueVO>> dicMap = this.sysDictionaryService.getMultiKvList(CurrentThreadContext.getFlServiceSysCd(), CurrentThreadContext.getCurrentOrgCd(), codeGrpCdList);
		view.addObject("reportTypeList", dicMap.get(FilFinanceConstant.CST_REPORT_TYPE_CD));// 报表类型
		view.addObject("reportsubTypeList", dicMap.get(FilFinanceConstant.CST_REPORT_SUB_TYPE_CD));// 报表类型细分
		view.addObject("cstBscInfo", vo);
		view.addObject("cstId", cstId);
		if(vo.getCstCorpBscInfoVO() != null && vo.getCstCorpBscInfoVO().getIsInst() != null && 1==vo.getCstCorpBscInfoVO().getIsInst().intValue()){
			//跳转事业单位页面
			view.setViewName("customer/filcreditfinance/filFinanceDebtZx");
		}else{
			//跳转非事业单位页面
			view.setViewName("customer/filcreditfinance/filFinanceDebt");
		}
		BaseLogUtils.info(logger, "toFilFinanceDebtPage", "跳转到财务报表cstId:" + cstId, CurrentThreadContext.getCurrentUserName());
		return view;
	}
	/**
	 * 跳转到财务报表查看页面
	 */
	@RequestMapping(value = "/toFilFinanceDebtDetailPage.do", method = { RequestMethod.GET})
	public ModelAndView toFilFinanceDebtDetailPage(HttpServletRequest request, HttpServletResponse response) {
		String cstId = request.getParameter("cstId");
		ModelAndView view = new ModelAndView();
		CstBscInfoVO vo = new CstBscInfoVO();
		if(StringUtils.isNotEmpty(cstId)){
			vo = this.cstBscInfoService.selectDetailById(Long.valueOf(cstId));
		}
		List<String> codeGrpCdList = new ArrayList<>();
		codeGrpCdList.add(FilFinanceConstant.CST_REPORT_TYPE_CD);//报表类型
		codeGrpCdList.add(FilFinanceConstant.CST_REPORT_SUB_TYPE_CD);//报表类型细分
		Map<String, List<KeyValueVO>> dicMap = this.sysDictionaryService.getMultiKvList(CurrentThreadContext.getFlServiceSysCd(), CurrentThreadContext.getCurrentOrgCd(), codeGrpCdList);
		view.addObject("reportTypeList", dicMap.get(FilFinanceConstant.CST_REPORT_TYPE_CD));// 报表类型
		view.addObject("reportsubTypeList", dicMap.get(FilFinanceConstant.CST_REPORT_SUB_TYPE_CD));// 报表类型细分
		view.addObject("cstBscInfo", vo);
		view.addObject("cstId", cstId);
		if(vo.getCstCorpBscInfoVO() != null && vo.getCstCorpBscInfoVO().getIsInst() != null && 1==vo.getCstCorpBscInfoVO().getIsInst().intValue()){
			//跳转事业单位页面
			view.setViewName("customer/filcreditfinance/filFinanceDebtZxDetail");
		}else{
			//跳转非事业单位页面
			view.setViewName("customer/filcreditfinance/filFinanceDebtDetail");
		}
		BaseLogUtils.info(logger, "toFilFinanceDebtDetailPage", "跳转到财务报表cstId:" + cstId, CurrentThreadContext.getCurrentUserName());
		return view;
	}
	/**
	 * 跳转到客户项目页面
	 */
	@RequestMapping(value = "/toCstProjectPage.do", method = { RequestMethod.GET})
	public ModelAndView toCstProjectPage(HttpServletRequest request, HttpServletResponse response) {
		String cstId = request.getParameter("cstId");
		String cstNm = request.getParameter("cstNm");
		ModelAndView view = new ModelAndView("customer/cstproject/cstProjectBscInfoList");
		view.addObject("cstId", cstId);
		view.addObject("cstNm", cstNm);
		//项目类型
		List<KeyValueVO> projectTypeList = this.prjBscInfoService.getProjectTypeList();
		//业务类型
		List<KeyValueVO> bizTypeList = this.prjBscInfoService.getBizTypeList();
		//项目状态
		List<KeyValueVO> prjStsList = this.prjBscInfoService.getPrjStsList();
		// 事业部
		List<KeyValueVO> orgList = this.cstBscInfoService.searchBusinessOrgList();

		//业务线字典List
		List<KeyValueVO> bussinessLineDicList = sysDictionaryService.getKvList("REF0048","11000","0000");
		//金融机构List
		List<FriBaseInfoVO> friBaseInfoVOList = this.friBaseInfoService.searchList(new FriBaseInfoQueryCondition());
		//根据金融机构业务线,设置金融机构名称展示字段值
		FundRasInsNmChangeUtil.insNmShowAddBussinessLineDic(friBaseInfoVOList,bussinessLineDicList);
		view.addObject("friBaseList",friBaseInfoVOList);

		view.addObject("orgListList", orgList);
		view.addObject("projectTypeList", projectTypeList);
		view.addObject("bizTypeList", bizTypeList);
		view.addObject("prjStsList", prjStsList);
		view.addObject("fromPrjFlag", false);
		view.addObject("currentBuOrgCd", CurrentThreadContext.getCurrentBuOrgCd());
		// 事业部
		List<String> orgCds = new ArrayList<>();
		orgCds.add(CurrentThreadContext.getCurrentBuOrgCd());
		view.addObject("orgCds", orgCds);
		BaseLogUtils.info(logger, "toCstProjectPage", "跳转到客户项目列表cstId:" + cstId, CurrentThreadContext.getCurrentUserName());
		return view;
	}
	
	
	/**
	 * 跳转到客户项目详细页面
	 */
	@RequestMapping(value = "/toCstProjectDetailPage.do", method = { RequestMethod.GET})
	public ModelAndView toCstProjectDetailPage(HttpServletRequest request, HttpServletResponse response) {
		String cstId = request.getParameter("cstId");
		String cstNm = request.getParameter("cstNm");
		String isLoan = request.getParameter("isLoan");
		ModelAndView view = new ModelAndView("customer/cstproject/cstProjectBscInfoDetailList");
		view.addObject("cstId", cstId);
		view.addObject("cstNm", cstNm);
		view.addObject("isLoan", isLoan);
		view.addObject("fromPrjFlag", false);
		BaseLogUtils.info(logger, "toCstProjectPage", "跳转到客户项目详细列表cstId:" + cstId, CurrentThreadContext.getCurrentUserName());
		return view;
	}
	/**
	 * 跳转到客户担保项目详细页面
	 */
	@RequestMapping(value = "/toPrjCstBscDetailPage.do", method = { RequestMethod.GET})
	public ModelAndView toPrjCstBscDetailPage(HttpServletRequest request, HttpServletResponse response) {
		String cstId = request.getParameter("cstId");
		String cstNm = request.getParameter("cstNm");
		ModelAndView view = new ModelAndView("customer/cstproject/prjCstBscInfoDetailList");
		view.addObject("cstId", cstId);
		view.addObject("cstNm", cstNm);
		view.addObject("fromPrjFlag", false);
		BaseLogUtils.info(logger, "toPrjCstBscDetailPage", "跳转到客户担保项目详细列表cstId:" + cstId, CurrentThreadContext.getCurrentUserName());
		return view;
	}
	
	/**
	 * 到客户通用弹出列表页面
	 */
	@RequestMapping(value = "/toPublicCompListPage.do", method = { RequestMethod.GET })
	public ModelAndView toPublicCompListPage(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView view = new ModelAndView("customer/cstcomp/cstChooseList");
		String multiRow = request.getParameter("multiRow");
		view.addObject("multiRow", multiRow);
		// 获取查询面板下拉框选项
		// 客户状态
		/*List<KeyValueVO> cststscdlist = this.cstBscInfoService.searchCstStsCdList();
		view.addObject("searchSelectCststscdlist", cststscdlist);*/
		// 客户类型
		List<KeyValueVO> csttypcdlist = this.cstBscInfoService.searchCstTypCdList();
		view.addObject("searchSelectCsttypcdlist", csttypcdlist);
		// 营业执照
		/*List<KeyValueVO> businesslicenceList = this.cstBscInfoService.searchBusinessLicenceList();
		view.addObject("searchSelectBusinessLicencelist", businesslicenceList);*/
		// 事业部
		List<KeyValueVO> orgList = this.cstBscInfoService.searchBusinessOrgList();
		view.addObject("orgListList", orgList);
		//客户关系属性
		/*List<KeyValueVO> cstRlTypCdList = this.cstBscInfoService.searchCstRlTypList();
		view.addObject("cstRlTypCdList", cstRlTypCdList);*/
		// 证件类型
		/*List<KeyValueVO> lpCertTypCdList = this.cstBscInfoService.searchCertTypCdList(CustomerConstant.CST_TYP_CD_CORP);
		view.addObject("searchSelectLPCertTypCdList", lpCertTypCdList);*/
		//查询项要有默认值,这里给出默认值到前端页面显示
		//view.addObject("currentBuOrgCd", CurrentThreadContext.getCurrentBuOrgCd());
		//view.addObject("currentCstRlType", DictionaryConstant.CODE_GRP_CST_RL_TYP_CD_1);
		BaseLogUtils.info(logger, "toPublicCompListPage", "跳转到客户通用弹出列表页面", CurrentThreadContext.getCurrentUserName());
		return view;
	}
	
	/**
	 * 到客户详细页面
	 */
	@RequestMapping(value = "/toCustDetailPage.do", method = { RequestMethod.GET})
	public ModelAndView toCustDetailPage(HttpServletRequest request, HttpServletResponse response) {
		String id = request.getParameter("id");
		String url = "";
		try {
			CstBscInfoVO cstBscInfoVO = this.cstBscInfoService.selectById(Long.valueOf(id));
			if(null != cstBscInfoVO){
				if(CustomerConstant.CST_TYP_CD_NP.equals(cstBscInfoVO.getCstTypCd())){
					url = "customer/cstbscinfo/custCstBacInfoNpDetail";
				}else if(CustomerConstant.CST_TYP_CD_CORP.equals(cstBscInfoVO.getCstTypCd())){
					url = "customer/cstbscinfo/custCstBacInfoCorpDetail";
				}
			}
		} catch (Exception e) {
			BaseLogUtils.error(logger, "toCustDetailPage", "跳转到客户详情页面错误. ID:" + id, CurrentThreadContext.getCurrentUserName(), e);
		}
		ModelAndView view = new ModelAndView(url);
		BaseLogUtils.info(logger, "toCustDetailPage", "跳转到客户详情页面. ID:" + id, CurrentThreadContext.getCurrentUserName());
		view.addObject("id", id);
		return view;
	}
	
	/**
	 * 初始化列表
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/initList.do", method = { RequestMethod.GET })
	@ResponseBody
	public Object initList(HttpServletRequest request, HttpServletResponse response) {
		String currentPage = request.getParameter("page");
		String pageSize = request.getParameter("pagesize");
		// 查询条件
		String cstNm = request.getParameter("cstNm");
		String cstTypCd = request.getParameter("cstTypCd");
		String cstStsCd = request.getParameter("cstStsCd");
		String certNo = request.getParameter("certNo");
		String cstCd = request.getParameter("cstCd");
		String crtTm = request.getParameter("crtTm");
		String businessLicence = request.getParameter("businessLicence");
		String sortName = request.getParameter("sortname");
		String sortOrder = request.getParameter("sortorder");
		String buOrgCd = request.getParameter("buOrgCd");
		String cstRlTyp = request.getParameter("cstRlTyp");
		String rskMarkerCd = request.getParameter("rskMarkerCd");

		Pager page = new Pager();
		if (StringUtils.isNotEmpty(currentPage)) {
			page.setCurrentPage(Integer.parseInt(currentPage));
		}

		if (StringUtils.isNotEmpty(pageSize)) {
			page.setEveryPage(Integer.parseInt(pageSize));
		}

		CstBscInfoQueryCondition qc = new CstBscInfoQueryCondition();
		Boolean isHasCon = false;
		if(StringUtils.isNotEmpty(buOrgCd)){
			qc.setOrgCdForSearch(buOrgCd);
			isHasCon = true;
		}
		
		if (StringUtils.isNotEmpty(cstNm)) {
			qc.setCstNm(cstNm);
			isHasCon = true;
		}

		if (StringUtils.isNotEmpty(cstTypCd)) {
			qc.setCstTypCd(cstTypCd);
			isHasCon = true;
		}

		if (StringUtils.isNotEmpty(cstStsCd)) {
			qc.setCstStsCd(cstStsCd);
			isHasCon = true;
		}

		if (StringUtils.isNotEmpty(certNo)) {
			qc.setCertNo(certNo);
			isHasCon = true;
		}

		if (StringUtils.isNotEmpty(cstCd)) {
			qc.setCstCd(cstCd);
			isHasCon = true;
		}

		if (StringUtils.isNotEmpty(crtTm)) {
			qc.setCrtTm(DateUtils.formatStringToDate(crtTm, DateUtils.YYYY_MM_DD));
			isHasCon = true;
		}

		if (StringUtils.isNotEmpty(businessLicence)) {
			qc.setBusinessLicence(businessLicence);
			isHasCon = true;
		}
		
		if(StringUtils.isNotEmpty(cstRlTyp)){
			qc.setRlTypCd(fl.customer.facade.framework.constant.DictionaryConstant.CODE_GRP_CST_RL_TYP_CD_1);
			qc.setRlVal(cstRlTyp);
		}
		if(StringUtils.isNotEmpty(rskMarkerCd)){
		    qc.setRskMarkerCd(rskMarkerCd);
        }
		
		// sortName 到服务端会转换成为数据库字段
		if (StringUtils.isNotEmpty(sortName) && StringUtils.isNotEmpty(sortOrder)) {
			qc.setSortName(sortName);
			qc.setSortOrder(sortOrder);
		}
		qc.setSysCd(CurrentThreadContext.getCurrentSysCd());
		qc.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
		qc.setCurrUsrId(CurrentThreadContext.getCurrentUserId());
		if(isHasCon){
			//qc.setIsHasCondition(BaseConstant.IS_YESNO_YES);//有条件则不用过滤组织架构
		}else{
			/*qc.setIsHasCondition(BaseConstant.IS_YESNO_NO);//需要把条件加上默认组织架构和数据权限组织架构
			List<String> orgCdList = new ArrayList<>();
			orgCdList.add(CurrentThreadContext.getCurrentOrgCd());
			qc.setOrgCdList(orgCdList);*/
			
			//qc.setOpUsrId(CurrentThreadContext.getCurrentUserId());
		}
		qc.setIsAuth(true);
		qc.setOpUsrId(CurrentThreadContext.getCurrentUserId());
		page.setCondition(qc);
		Pager pager = this.cstBscInfoService.searchListPage(page);
		List<CstBscInfoVO> list = (List<CstBscInfoVO>) pager.getResultList();
		if(CollectionUtils.isNotEmpty(list)){
			String roleIsEncrypt=this.sysDictionaryService.getRoleisEncrypt();
			// 添加风险标记原因后的客户列表
			List<CstBscInfoVO> newList = new ArrayList<>();
			for (CstBscInfoVO cstBscInfoVO : list) {
				List<String> rskCdNms = new ArrayList<>();
				StringBuffer sb = new StringBuffer();
				if ("1".equals(cstBscInfoVO.getRskMarkerCd())) {
					RskCstSignLogQueryCondition condition = new RskCstSignLogQueryCondition();
					condition.setCstId(cstBscInfoVO.getId());
					condition.setSignSource(SplRelLogBizTypCdNum.CST.getBizTypCd());
					condition.setCstTypeCd(RiskCstSignLogConstant.CODE_GRP_NM_CST_RISK_TYPE_CD_1);
					condition.setIsDel(BaseConstant.IS_YESNO_NO);
					condition.setIsNew(BaseConstant.IS_YESNO_YES);
					condition.setIsValid(BaseConstant.IS_YESNO_YES);
					List<RskCstSignLogVO> rskCstSignLogVOList = rskCstSignLogService.searchList(condition);
					if(CollectionUtils.isNotEmpty(rskCstSignLogVOList)){
						List<KeyValueVO> rskCdList = rskCstSignLogService.searchCdList(DictionaryConstant.CUST_RISK_REASON);
						if(CollectionUtils.isNotEmpty(rskCdList)){
							for (RskCstSignLogVO rskCstSignLogVO : rskCstSignLogVOList) {
								String signResCd = rskCstSignLogVO.getSignResCd();
								for (KeyValueVO rskCd : rskCdList) {
									if (StringUtils.isNotEmpty(signResCd) && signResCd.equals(rskCd.getKey())) {
										if (!rskCdNms.contains(rskCd.getValue())) {
											rskCdNms.add(rskCd.getValue());
										}
									}
								}
							}
						}
					}
				}
				if(CollectionUtils.isNotEmpty(rskCdNms)){
					for (int i = 0; i < rskCdNms.size(); i++) {
						sb.append(rskCdNms.get(i));
						if (i != rskCdNms.size() - 1) {
							sb.append("、");
						}
					}
					cstBscInfoVO.setRskCdNms(sb.toString());
				}
				if(BaseConstant.IS_YESNO_YES_STR.equals(roleIsEncrypt)) {
					cstBscInfoVO.setCertNo(EncryptUtil.certNoEncrypt(cstBscInfoVO.getCertNo()));
				}
				newList.add(cstBscInfoVO);
			}
		}
		ListPageVO<CstBscInfoVO> listPage = new ListPageVO<CstBscInfoVO>(list, pager.getTotalCount());
		BaseLogUtils.info(logger, "initList", "初始化列表数据.DATA:" + com.alibaba.fastjson.JSONObject.toJSONString(page), CurrentThreadContext.getCurrentUserName());
		return listPage;
	}
	
	/**
	 * 初始化组织架构树
	 */
	@RequestMapping(value = "/initOrgTree.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object initOrgTree(HttpServletRequest request, HttpServletResponse response) {
		try {
			JSONArray jsonArray = this.cstBscInfoService.searchCurrentOrgWithChildTree();
			BaseLogUtils.info(logger, "initOrgTree", "初始化组织架构树.",CurrentThreadContext.getCurrentUserName());
			return jsonArray;
		} catch (Exception e) {
			BaseLogUtils.error(logger, "-", "异常", e);
			BaseLogUtils.error(logger, "initOrgTree", "初始化组织架构树.系统错误！",CurrentThreadContext.getCurrentUserName(), e);
		}
		return new JSONArray();
	}

	/**
	 * 删除数据
	 */
	@RequestMapping(value = "/removeByIds.do", method = { RequestMethod.POST })
	@ResponseBody
	public DataResultVO removeByIds(HttpServletRequest request, HttpServletResponse response)
			throws BaseException, BaseException {
		String ids = request.getParameter("ids");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_DELETE_SUCC);
		if (StringUtils.isEmpty(ids)) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.info(logger, "removeByIds", "主键参数不存在!", CurrentThreadContext.getCurrentUserName());
			return result;
		}

		List<Long> idsList = new ArrayList<Long>();
		JSONArray idsArray = JSONArray.fromObject(ids);
		for (Object object : idsArray) {
			idsList.add(Long.valueOf(object.toString()));
		}

		try {
			boolean success = this.cstBscInfoService.removeByIds(idsList);
			if (!success) {
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_DELETE_FAIL);
				BaseLogUtils.info(logger, "removeByIds", "删除失败! DATA:" + com.alibaba.fastjson.JSONObject.toJSONString(idsList), CurrentThreadContext.getCurrentUserName());
			}else{
				BaseLogUtils.info(logger, "removeByIds", "删除成功! DATA:" + com.alibaba.fastjson.JSONObject.toJSONString(idsList), CurrentThreadContext.getCurrentUserName());
			}
		} catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "removeByIds", "删除失败! DATA:" + com.alibaba.fastjson.JSONObject.toJSONString(idsList), CurrentThreadContext.getCurrentUserName(), ex);
		} catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "removeByIds", "删除失败! DATA:" + com.alibaba.fastjson.JSONObject.toJSONString(idsList), CurrentThreadContext.getCurrentUserName(), ex);
		}

		return result;
	}

	/**
	 * 修改数据,得到一条记录
	 * 
	 * @param request
	 * @return
	 * @throws BaseException
	 */
	@RequestMapping(value = "/getById.do", method = { RequestMethod.GET })
	@ResponseBody
	public Object getById(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");
		String isEncrypt=request.getParameter("isEncrypt");

		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		if (StringUtils.isEmpty(id)) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			return result;
		}
		try {
			String roleIsEncrypt=this.sysDictionaryService.getRoleisEncrypt();

			CstBscInfoVO vo = this.cstBscInfoService.selectBy(Long.valueOf(id), 
					CurrentThreadContext.getCurrentBuOrgCd());
			
			if (null == vo) {
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_QUERY_DATA_IS_EMPTY);
				BaseLogUtils.info(logger, "getById", "获取数据不存在! ID:" + id, CurrentThreadContext.getCurrentUserName());
			}else {
				BaseLogUtils.info(logger, "getById", "获取数据成功! ID:" + id, CurrentThreadContext.getCurrentUserName());
				if (StringUtils.isNotEmpty(isEncrypt) && BaseConstant.IS_YESNO_YES_STR.equals(isEncrypt) && BaseConstant.IS_YESNO_YES_STR.equals(roleIsEncrypt)) {
					vo.setCertNo(EncryptUtil.certNoEncrypt(vo.getCertNo()));
					if (null != vo.getCstNpBscInfoVO()) {
						String mp1 = EncryptUtil.mobileEncrypt(vo.getCstNpBscInfoVO().getMp1());
						vo.getCstNpBscInfoVO().setMp1(mp1);
					}
				}
			}
			result.setData(vo);
		} catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "getById", "获取数据失败! ID:" + id, CurrentThreadContext.getCurrentUserName(), ex);
		} catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "getById", "获取数据失败! ID:" + id, CurrentThreadContext.getCurrentUserName(), ex);
		}
		return result;
	}

    /**
     * 根据ID查询 法人自然人详情
     * @param id
     * @return
     */
	@RequestMapping(value = "showDetail",method = RequestMethod.GET)
	public String showDetail(String id){
		CstBscInfoVO cstBscInfoVO = this.cstBscInfoService.selectDetailById(Long.valueOf(id));
		if(cstBscInfoVO.getCstTypCd().equals("1")){//自然人
			return "redirect:/customer/cstbscinfo/toCustCstBacInfoNpDetailPage.do?id="+id;
		}else if(cstBscInfoVO.getCstTypCd().equals("2")){ // 法人
			return "redirect:/customer/cstbscinfo/toCustCstBacInfoCorpDetailPage.do?id="+id;
		}
        return "redirect:/customer/cstbscinfo/toCustCstBacInfoNpDetailPage.do?id="+id;
	}

	/**
	 * 详细信息-获取客户信息
	 */
	@RequestMapping(value = "/getShowDetailById.do", method = { RequestMethod.GET })
	@ResponseBody
	public Object getShowDetailById(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");
		String isEncrypt=request.getParameter("isEncrypt");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		if (StringUtils.isEmpty(id)) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.info(logger, "getShowDetailById", "获取数据参数不存在!", CurrentThreadContext.getCurrentUserName());
			return result;
		}
		try {
			CstBscInfoVO vo = this.cstBscInfoService.selectDetailById(Long.valueOf(id));
			String roleIsEncrypt=this.sysDictionaryService.getRoleisEncrypt();
			if (null == vo) {
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_QUERY_DATA_IS_EMPTY);
				BaseLogUtils.info(logger, "getShowDetailById", "获取数据不存在! id:" + id, CurrentThreadContext.getCurrentUserName());
			}else{
				if(StringUtils.isNotEmpty(vo.getIsFarmer())){
					if(BaseConstant.IS_YESNO_YES == vo.getIsFarmer()){
						vo.setIsFarmerNm(BaseConstant.IS_YESNO_YES_NM);
					}else{
						vo.setIsFarmerNm(BaseConstant.IS_YESNO_NO_NE);
					}
				}
				if(StringUtils.isNotEmpty(isEncrypt) && BaseConstant.IS_YESNO_YES_STR.equals(isEncrypt) && BaseConstant.IS_YESNO_YES_STR.equals(roleIsEncrypt)) {
					vo.setCertNo(EncryptUtil.certNoEncrypt(vo.getCertNo()));
					if(null != vo.getCstNpBscInfoVO()){
						String mp1=EncryptUtil.mobileEncrypt(vo.getCstNpBscInfoVO().getMp1());
						vo.getCstNpBscInfoVO().setMp1(mp1);
						if(null != vo.getCstNpBscInfoVO().getCstNpSocialRlVO()){
							vo.getCstNpBscInfoVO().getCstNpSocialRlVO().setCertNo(EncryptUtil.certNoEncrypt(vo.getCstNpBscInfoVO().getCstNpSocialRlVO().getCertNo()));
							vo.getCstNpBscInfoVO().getCstNpSocialRlVO().setMp(EncryptUtil.mobileEncrypt(vo.getCstNpBscInfoVO().getCstNpSocialRlVO().getMp()));
						}
					}else if(null != vo.getCstCorpBscInfoVO()){
						vo.getCstCorpBscInfoVO().setBizLicNo(EncryptUtil.certNoEncrypt(vo.getCstCorpBscInfoVO().getBizLicNo()));
						vo.getCstCorpBscInfoVO().setTaxRegNo(EncryptUtil.certNoEncrypt(vo.getCstCorpBscInfoVO().getTaxRegNo()));
						vo.getCstCorpBscInfoVO().setSucc(EncryptUtil.certNoEncrypt(vo.getCstCorpBscInfoVO().getSucc()));
						vo.getCstCorpBscInfoVO().setLoanCardCd(EncryptUtil.certNoEncrypt(vo.getCstCorpBscInfoVO().getLoanCardCd()));

						if(null != vo.getCstCorpBscInfoVO().getCstCorpTeamVO()) {
							String certNo = vo.getCstCorpBscInfoVO().getCstCorpTeamVO().getCertNo();
							String mp = vo.getCstCorpBscInfoVO().getCstCorpTeamVO().getMp1();
							vo.getCstCorpBscInfoVO().getCstCorpTeamVO().setCertNo(EncryptUtil.certNoEncrypt(certNo));
							vo.getCstCorpBscInfoVO().getCstCorpTeamVO().setMp1(EncryptUtil.mobileEncrypt(mp));
						}
					}
				}
			}
			result.setData(vo);
		} catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "getShowDetailById", "获取数据失败! ID:" + id, CurrentThreadContext.getCurrentUserName(), ex);
		} catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "getShowDetailById", "获取数据失败! ID:" + id, CurrentThreadContext.getCurrentUserName(), ex);
		}
		return result;
	}
	
	/**
	 * 新增自然人
	 */
	@RequestMapping(value = "/addNp.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object addNp(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_ADD_SUCC);
		CstBscInfoVO cstBscInfoVO = null;
		try {
			//新增前需要先检查系统是否存在用户信息
			String certNo = request.getParameter("certNo");// 证件号码
			String cstNm = request.getParameter("cstNm");// 证件名称
			String certTypCd = request.getParameter("certTypCd");
			String cstRlTyp = request.getParameter("cstRlTyp");//客户关系属性
			//获取参数并验证
			cstBscInfoVO = this.getRequestParamForNpAdd(request);
			if(cstBscInfoVO.getCertTypCd().equals(DictionaryConstant.CODE_CERT_TYP_CD_0)){
				this.checkCstVIDInfoItemNp(request);
			}
			//设置随机征信信息
			this.setRandomDefaultValue(cstBscInfoVO);

			//需要单独检查证件号是否存在
			CstBscInfoQueryCondition qcCertNo = new CstBscInfoQueryCondition();
			qcCertNo.setCertNo(certNo);
			qcCertNo.setCstTypCd(cstBscInfoVO.getCstTypCd());
			qcCertNo.setSysCd(CurrentThreadContext.getCurrentSysCd());
			List<CstBscInfoVO> checkList = this.cstBscInfoService.searchCstBscInfoWithCertNo(qcCertNo);
			if(CollectionUtils.isNotEmpty(checkList)){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CUST_INFO_IS_HERE);
				BaseLogUtils.info(logger, "addCorp", "客户信息已经存在,不能重复添加! certNo:" + certNo, CurrentThreadContext.getCurrentUserName());
				return result;
			}
			
			//验证手机号在数据库中是否唯一,现在是需要验证两个手机号
			CstNpBscInfoQueryCondition qc = new CstNpBscInfoQueryCondition();
			CstNpBscInfoVO cstNpBscInfoVO = cstBscInfoVO.getCstNpBscInfoVO();
			if(null != cstNpBscInfoVO){
				qc.setMp1(cstNpBscInfoVO.getMp1());
				qc.setMp2(cstNpBscInfoVO.getMp2());
			}
			//qc.setCstTypCd(cstBscInfoVO.getCstTypCd());//自然人
			qc.setSysCd(CurrentThreadContext.getCurrentSysCd());
			
			List<CstNpBscInfoVO> list = this.cstBscInfoService.searchCstNpBscInfoWithMp(qc);
			if(CollectionUtils.isNotEmpty(list)){
				CstNpBscInfoVO cstNpBscInfoVOTemp = list.get(0);
				StringBuffer sb = new StringBuffer();
				if(null != cstNpBscInfoVO.getMp1()){
					if(cstNpBscInfoVOTemp.getMp1().equals(cstNpBscInfoVO.getMp1())){
						if(!sb.toString().contains(cstNpBscInfoVO.getMp1())){
							sb.append(cstNpBscInfoVO.getMp1());
							sb.append(";");
						}
					}
				}

				if(null != cstNpBscInfoVO.getMp2()){
					if(cstNpBscInfoVO.getMp2().equals(cstNpBscInfoVOTemp.getMp2())){
						if(sb.toString().contains(cstNpBscInfoVOTemp.getMp2())){
							sb.append(cstNpBscInfoVO.getMp2());
							sb.append(";");
						}
					}
				}

				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CUST_VALID_MP_ONLY_ONE + sb.toString());
				BaseLogUtils.info(logger, "addNp", "客户手机号与系统内有重复信息! DATA:" + com.alibaba.fastjson.JSONObject.toJSONString(cstBscInfoVO), CurrentThreadContext.getCurrentUserName());
				return result;
			}
			
			CstNpSocialRlVO cstNpSocialRlVO = cstBscInfoVO.getCstNpBscInfoVO().getCstNpSocialRlVO();
			if(null != cstNpSocialRlVO && cstNpSocialRlVO.getCertTypCd().equals(DictionaryConstant.CODE_CERT_TYP_CD_0)){
				validCert(cstNpSocialRlVO.getRlNm(), cstNpSocialRlVO.getCertNo(), "客户配偶身份信息验证失败!", "addNp");
				
			}
			//手机三要素核查
			boolean checkMp=this.cstBscInfoService.checkMpAndCert(cstBscInfoVO.getCstNm(),cstBscInfoVO.getCertNo(),cstNpBscInfoVO.getMp1());
			if (!checkMp){
				BaseLogUtils.info(logger, "addNp", "手机三要素校验失败");
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo("手机三要素校验失败");
				return result;
			}else{
				cstBscInfoVO.getCstNpBscInfoVO().setLivAudStsCd(CustomerConstant.CST_CHECK_STS_D_0);
				cstBscInfoVO.getCstNpBscInfoVO().setMpStsCd(CustomerConstant.CST_CHECK_STS_D_1);
			}
			//把身份证照片地址保存上
			Long id = this.cstBscInfoService.add(cstBscInfoVO);
			result.setData(id);
			//上传附件
			uploadAttchment(request, result, id);
			BaseLogUtils.info(logger, "addNp", "新增成功! DATA:" + com.alibaba.fastjson.JSONObject.toJSONString(cstBscInfoVO), CurrentThreadContext.getCurrentUserName());
		} catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "addNp", "新增失败! DATA:" + com.alibaba.fastjson.JSONObject.toJSONString(cstBscInfoVO), CurrentThreadContext.getCurrentUserName(), ex);
		} catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "addNp", "新增失败! DATA:" + com.alibaba.fastjson.JSONObject.toJSONString(cstBscInfoVO), CurrentThreadContext.getCurrentUserName(), ex);
		}

		return result;
	}
	
	private void uploadAttchment(HttpServletRequest request, DataResultVO result, Long id) {
		String attchmnt = request.getParameter("docArray");
		if(StringUtils.isNotEmpty(attchmnt)){
			//上传解析
			try{
				String cfgCd = PropertiesCacheUtils.getProperty(CustomerConstant.CST_BSCINFO_CFGCD);
				String cfgDtlCd = PropertiesCacheUtils.getProperty(CustomerConstant.CST_BSCINFO_CFGDTLCD);
				String tabNm = PropertiesCacheUtils.getProperty(CustomerConstant.CST_BSCINFO_TABNM);
				String cfgOrgCd = PropertiesCacheUtils.getProperty(CustomerConstant.CST_BSCINFO_CFGORG);
				Boolean attchmntPass = this.sysUlFilesRecService.addAttchmnt(String.valueOf(id), attchmnt, cfgCd, cfgDtlCd, tabNm, "客户主要信息附件!", null, null, false, cfgOrgCd);
				if(null == attchmntPass || attchmntPass == false){
					result.setInfo(result.getInfo()+"-附件上传失败!");
				}
			}catch(Exception e){
				BaseLogUtils.error(logger, "uploadAttchment", result.getInfo()+"-附件上传失败!", e);
				result.setInfo(result.getInfo()+"-附件上传失败!");
			}
		}
	}

	/**
	 * 修改自然人
	 */
	@RequestMapping(value = "/modifyNp.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object modifyNp(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_UPDATE_SUCC);
		CstBscInfoVO cstBscInfoVO = null;
		try {
			String modFlag = request.getParameter("modFlag");//操作标识：修改（空）、基础变更（yes）
			cstBscInfoVO = this.getRequestParamForNpModify(request);
			String certNo = cstBscInfoVO.getCertNo();
			String cstNm = cstBscInfoVO.getCstNm();
			if(cstBscInfoVO.getCertTypCd().equals(DictionaryConstant.CODE_CERT_TYP_CD_0)){
				this.checkCstVIDInfoItemNp(request);
				//验证身份信息
                checkCstCertNo(cstBscInfoVO);
			}
			//需要单独检查证件号是否存在
			CstBscInfoQueryCondition qc = new CstBscInfoQueryCondition();
			qc.setCertNo(cstBscInfoVO.getCertNo());
			qc.setCstTypCd(cstBscInfoVO.getCstTypCd());//自然人
			qc.setSysCd(CurrentThreadContext.getCurrentSysCd());
			List<CstBscInfoVO> checkList = this.cstBscInfoService.searchCstBscInfoWithCertNo(qc);
			if(CollectionUtils.isNotEmpty(checkList)){
				Boolean pass = true;
				for (CstBscInfoVO cstBscInfoVO2 : checkList) {
					if(!cstBscInfoVO.getId().equals(cstBscInfoVO2.getId())){//过滤掉自己
						pass = false;
						break;
					}
				}
				
				if(!pass){
					result.setSuccess(BaseConstant.IS_YESNO_NO);
					result.setInfo(SysLogConstant.LOG_CUST_INFO_IS_HERE);
					BaseLogUtils.info(logger, "modifyNp", "客户信息已经存在! certNo:" + cstBscInfoVO.getCertNo(), CurrentThreadContext.getCurrentUserName());
					return result;
				}
			}
			
			Long id = cstBscInfoVO.getId();
			//验证用户配偶信息是否修改过,如果不同则要验证身份证是否正确
			CstNpSocialRlVO cstNpSocialRlVO = cstBscInfoVO.getCstNpBscInfoVO().getCstNpSocialRlVO();
			if(null != cstNpSocialRlVO && cstNpSocialRlVO.getCertTypCd().equals(DictionaryConstant.CODE_CERT_TYP_CD_0)){
				CstNpSocialRlDTO cstNpSocialRlDTO = this.cstBscInfoService.searchCstNpSocialRlList(id, DictionaryConstant.CODE_GRP_RL_TYP_CD_5);
				boolean isValid = true;
				String newRlNm = cstNpSocialRlVO.getRlNm();
				String newRlCertNo = cstNpSocialRlVO.getCertNo();
				if(null != cstNpSocialRlDTO){
					isValid = false;
					//说明有旧的配偶信息
					String oldRlNm = cstNpSocialRlDTO.getRlNm();
					String oldRlCertNo = cstNpSocialRlDTO.getCertNo();
					//只要有一个不相等则校验
					if(!newRlNm.equals(oldRlNm) || !newRlCertNo.equals(oldRlCertNo)){
						isValid = true;
					}
				}
				if(isValid){
					//原先没有直接验证
					validCert(newRlNm, newRlCertNo, "客户配偶身份验证未通过!", "modifyNp");
				}
			}
			
			//判断操作是"修改",还是"基础变更"-20190419-JL
			if(StringUtils.isNotEmpty(modFlag) && "yes".equals(modFlag)){
				//调用流程操作：申请、修改
				return this.cstModFlowOperate(request, response, cstBscInfoVO);
			}else{//"修改"操作
				boolean success = this.cstBscInfoService.modify(cstBscInfoVO);
				if (!success) {
					result.setSuccess(BaseConstant.IS_YESNO_NO);
					result.setInfo(SysLogConstant.LOG_CMM_UPDATE_FAIL);
					BaseLogUtils.info(logger, "modifyNp", "修改失败! DATA:" + com.alibaba.fastjson.JSONObject.toJSONString(cstBscInfoVO), CurrentThreadContext.getCurrentUserName());
				}else{
					result.setData(id);
					//上传附件
					uploadAttchment(request, result, id);
					//加入承租人照片
					//this.uploadCstIDImg(request, cstBscInfoVO, id);
					BaseLogUtils.info(logger, "modifyNp", "修改成功! DATA:" + com.alibaba.fastjson.JSONObject.toJSONString(cstBscInfoVO), CurrentThreadContext.getCurrentUserName());
				}
			}
		} catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "modifyNp", "修改失败! DATA:" + com.alibaba.fastjson.JSONObject.toJSONString(cstBscInfoVO), CurrentThreadContext.getCurrentUserName(), ex);
		} catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "modifyNp", "修改失败! DATA:" + com.alibaba.fastjson.JSONObject.toJSONString(cstBscInfoVO), CurrentThreadContext.getCurrentUserName(), ex);
		}
		return result;
	}

	/**
	 * 证件验证
	 * @param certNm 证件名称
	 * @param certNo 证件号码
	 * @param desc 描述
	 */
	private CstValidCardInfoVO validCert(String certNm, String certNo, String errorDesc, String funName) {
		CstValidCardInfoVO cstValidCardInfoVO = this.cstBscInfoService.validateCstCert(certNm, certNo);
		if(!cstValidCardInfoVO.getSuccess()){
			//第三方验证未通过
			String info = errorDesc+" certNm:" + certNm + " - certNo:" +certNo;
			BaseLogUtils.info(logger, funName, info, CurrentThreadContext.getCurrentUserName());
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, errorDesc);
		}
		return cstValidCardInfoVO;
	}

	/**
	 * 新增法人
	 */
	@RequestMapping(value = "/addCorp.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object addCorp(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_ADD_SUCC);
		CstBscInfoVO cstBscInfoVO = null;
		try {
			cstBscInfoVO = this.getRequestParamForCorpAdd(request);
			//新增前需要先检查系统是否存在用户信息
			String certNo = request.getParameter("certNo");// 证件号码
			String cstNm = request.getParameter("cstNm");// 企业名称
			String certTypCd = request.getParameter("certTypCd");//证件类型
			String dataList = request.getParameter("dataList");//主要成员字符串
			Boolean success = false;
			List<CstBscInfoVO> cstBscInfoVOList = this.cstBscInfoService.checkCstBscInfoCorpIsHere(cstNm,certNo, certTypCd, CurrentThreadContext.getCurrentSysCd());
			if(CollectionUtils.isNotEmpty(cstBscInfoVOList)){
				success = true;
			}
			//需要单独检查证件号是否存在
			CstBscInfoQueryCondition condition = new CstBscInfoQueryCondition();
			condition.setSysCd(CurrentThreadContext.getCurrentSysCd());
			condition.setCstTypCd(CustomerConstant.CST_TYP_CD_CORP);
			condition.setCstNmAll(cstNm);
			List<CstBscInfoVO> cstList = this.cstBscInfoService.searchListByCon(condition);
			if(CollectionUtils.isNotEmpty(cstList)){
				success = true;
			}
			if(success){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CUST_INFO_IS_HERE);
				BaseLogUtils.info(logger, "addCorp", "客户信息已经存在,不能重复添加! certNo:" + certNo, CurrentThreadContext.getCurrentUserName());
				return result;
			}
			BaseLogUtils.info(logger,"addCorp","新增法人数据.法人团队信息准备数据：" + dataList);
			List<CstCorpTeamVO> cstCorpTeamVOList = new ArrayList<CstCorpTeamVO>();
			if(StringUtils.isNotBlank(dataList)){
				String[] dtlt = dataList.split("@");
				if(dtlt!=null&&dtlt.length>0){
					for(String dtls:dtlt){
						if(StringUtils.isNotBlank(dtls)){
							String[] dtl = dtls.split(",");
							if(dtl!=null&&dtl.length>0
									&&StringUtils.isNotBlank(dtl[2])&&dtl[2].length()>1
									&&StringUtils.isNotBlank(dtl[3])&&dtl[3].length()>1){
								CstCorpTeamVO vo = new CstCorpTeamVO();
								//vo.setCstId(id);
								vo.setBuOrgCd(CurrentThreadContext.getCurrentBuOrgCd());
								vo.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
								vo.setIsDel(0);
								if(StringUtils.isNotBlank(dtl[1])&&dtl[1].length()>1){//成员类型
									vo.setMTypCd(dtl[1].substring(0,dtl[1].length()-1));
								}
								if(StringUtils.isNotBlank(dtl[2])&&dtl[2].length()>1){//姓名
									vo.setMNm(dtl[2].substring(0,dtl[2].length()-1));
								}
								if(StringUtils.isNotBlank(dtl[3])&&dtl[3].length()>1){//证件号
									vo.setCertNo(dtl[3].substring(0,dtl[3].length()-1));
								}
								if(StringUtils.isNotBlank(dtl[4])&&dtl[4].length()>1){//手机号
									vo.setMp1(dtl[4].substring(0,dtl[4].length()-1));
								}
								if(StringUtils.isNotBlank(dtl[5])&&dtl[5].length()>1){//证件类型
									vo.setCertTypCd(dtl[5].substring(0,dtl[5].length()-1));
								}
								if(StringUtils.isNotBlank(dtl[0])&&dtl[0].length()>1){//主键
									if(StringUtils.isNotBlank(dtl[0])&&dtl[0].length()>1){
										vo.setId(Long.valueOf(dtl[0].substring(0,dtl[0].length()-1)));
									}
									vo.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
									vo.setMdfTm(new Date());
									//this.cstCorpTeamService.modify(vo);
									cstCorpTeamVOList.add(vo);
								}else{
									vo.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
									vo.setCrtTm(new Date());
									//this.cstCorpTeamService.add(vo);
									cstCorpTeamVOList.add(vo);
								}
							}
						}
					}
				}
			}
			cstBscInfoVO.setCstCorpTeamVOList(cstCorpTeamVOList);
			BaseLogUtils.info(logger,"addCorp","新增法人数据.准备数据：" + JSON.toJSONString(cstBscInfoVO));
			Long id = this.cstBscInfoService.add(cstBscInfoVO);
			result.setData(id);
			//上传附件
			uploadAttchment(request, result, id);
			BaseLogUtils.info(logger, "addCorp", "新增成功! DATA:" + com.alibaba.fastjson.JSONObject.toJSONString(cstBscInfoVO), CurrentThreadContext.getCurrentUserName());
		} catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "addCorp", "新增失败[BaseException]! DATA:" + com.alibaba.fastjson.JSONObject.toJSONString(cstBscInfoVO), CurrentThreadContext.getCurrentUserName(), ex);
		} catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "addCorp", "新增失败[Exception]! DATA:" + com.alibaba.fastjson.JSONObject.toJSONString(cstBscInfoVO), CurrentThreadContext.getCurrentUserName(), ex);
		}
		return result;
	}

	/**
	 * 修改法人
	 */
	@RequestMapping(value = "/modifyCorp.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object modifyCorp(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_UPDATE_SUCC);
		String modFlag = request.getParameter("modFlag");//操作标识：修改（空）、基础变更（yes）
		CstBscInfoVO cstBscInfoVO = null;
		try {
			cstBscInfoVO = this.getRequestParamForCorpModify(request);
			String dataList = request.getParameter("dataList");//主要成员字符串
			//需要单独检查证件号是否存在
			CstBscInfoQueryCondition qc = new CstBscInfoQueryCondition();
			qc.setCstNmAll(cstBscInfoVO.getCstNm());
			qc.setCstTypCd(cstBscInfoVO.getCstTypCd());//企业
			qc.setSysCd(CurrentThreadContext.getCurrentSysCd());
			List<CstBscInfoVO> checkList = this.cstBscInfoService.searchListByCon(qc);
			if(CollectionUtils.isNotEmpty(checkList)){
				Boolean pass = true;
				for (CstBscInfoVO cstBscInfoVO2 : checkList) {
					if(!cstBscInfoVO.getId().equals(cstBscInfoVO2.getId())){//过滤掉自己
						pass = false;
						break;
					}
				}
				
				if(!pass){
					result.setSuccess(BaseConstant.IS_YESNO_NO);
					result.setInfo(SysLogConstant.LOG_CUST_INFO_IS_HERE);
					BaseLogUtils.info(logger, "addCorp", "客户信息已经存在! certNo:" + cstBscInfoVO.getCertNo(), CurrentThreadContext.getCurrentUserName());
					return result;
				}
			}
			BaseLogUtils.info(logger,"modifyCorp","修改法人数据.法人团队信息准备数据：" + dataList);
			List<CstCorpTeamVO> cstCorpTeamVOList = new ArrayList<CstCorpTeamVO>();
			if(StringUtils.isNotBlank(dataList)){
				String[] dtlt = dataList.split("@");
				if(dtlt!=null&&dtlt.length>0){
					for(String dtls:dtlt){
						if(StringUtils.isNotBlank(dtls)){
							String[] dtl = dtls.split(",");
							if(dtl!=null&&dtl.length>0
									&&StringUtils.isNotBlank(dtl[2])&&dtl[2].length()>1
									&&StringUtils.isNotBlank(dtl[3])&&dtl[3].length()>1){
								CstCorpTeamVO vo = new CstCorpTeamVO();
								//vo.setCertTypCd("0");
								vo.setCstId(cstBscInfoVO.getId());
								vo.setBuOrgCd(CurrentThreadContext.getCurrentBuOrgCd());
								vo.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
								vo.setIsDel(0);
								if(StringUtils.isNotBlank(dtl[1])&&dtl[1].length()>1){//成员类型
									vo.setMTypCd(dtl[1].substring(0,dtl[1].length()-1));
								}
								if(StringUtils.isNotBlank(dtl[2])&&dtl[2].length()>1){//姓名
									vo.setMNm(dtl[2].substring(0,dtl[2].length()-1));
								}
								if(StringUtils.isNotBlank(dtl[3])&&dtl[3].length()>1){//证件号
									vo.setCertNo(dtl[3].substring(0,dtl[3].length()-1));
								}
								if(StringUtils.isNotBlank(dtl[4])&&dtl[4].length()>1){//手机号
									vo.setMp1(dtl[4].substring(0,dtl[4].length()-1));
								}
								if(StringUtils.isNotBlank(dtl[5])&&dtl[5].length()>1){//证件类型
									vo.setCertTypCd(dtl[5].substring(0,dtl[5].length()-1));
								}
								if(StringUtils.isNotBlank(dtl[0])&&dtl[0].length()>1){//主键
									if(StringUtils.isNotBlank(dtl[0])&&dtl[0].length()>1){
										vo.setId(Long.valueOf(dtl[0].substring(0,dtl[0].length()-1)));
									}
									vo.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
									vo.setMdfTm(new Date());
									//this.cstCorpTeamService.modify(vo);
									cstCorpTeamVOList.add(vo);
								}else{
									vo.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
									vo.setCrtTm(new Date());
									//this.cstCorpTeamService.add(vo);
									cstCorpTeamVOList.add(vo);
								}
							}
						}
					}
				}
			}
			cstBscInfoVO.setCstCorpTeamVOList(cstCorpTeamVOList);
			BaseLogUtils.info(logger,"modifyCorp","修改法人数据.准备数据：" + JSON.toJSONString(cstBscInfoVO));
			
			//判断操作是"修改",还是"基础变更"-20190422-JL
			if(StringUtils.isNotEmpty(modFlag) && "yes".equals(modFlag)){
				//调用流程操作：申请、修改
				return this.cstModFlowOperate(request, response, cstBscInfoVO);
			}else{//"修改"操作
				boolean success = this.cstBscInfoService.modify(cstBscInfoVO);
				if (!success) {
					result.setSuccess(BaseConstant.IS_YESNO_NO);
					result.setInfo(SysLogConstant.LOG_CMM_UPDATE_FAIL);
					BaseLogUtils.info(logger, "modifyCorp", "修改失败! DATA:" + com.alibaba.fastjson.JSONObject.toJSONString(cstBscInfoVO), CurrentThreadContext.getCurrentUserName());
				}else{
					result.setData(cstBscInfoVO.getId());
					uploadAttchment(request, result, cstBscInfoVO.getId());
					BaseLogUtils.info(logger, "modifyCorp", "修改成功! DATA:" + com.alibaba.fastjson.JSONObject.toJSONString(cstBscInfoVO), CurrentThreadContext.getCurrentUserName());
				}
			}
		} catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "modifyCorp", "修改失败! DATA:" + com.alibaba.fastjson.JSONObject.toJSONString(cstBscInfoVO), CurrentThreadContext.getCurrentUserName(), ex);
		} catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "modifyCorp", "修改失败! DATA:" + com.alibaba.fastjson.JSONObject.toJSONString(cstBscInfoVO), CurrentThreadContext.getCurrentUserName(), ex);
		}
		return result;
	}
	/**
	 * 身份证验证
	 */
	@RequestMapping(value = "/validateIdCard.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object validateIdCard(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String cstNm = request.getParameter("cstNm");
		String certNo = request.getParameter("certNo");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CUST_ID_VALID_SUCC);		
		try {
			//验证身份证号格式
			this.checkCstVIDInfoItemNp(request);
			CstValidCardInfoVO cstValidCardInfoVO = this.validCert(cstNm, certNo, "身份证信息验证未通过!", "validateIdCard");
			JSONObject obj = new JSONObject();
			obj.put("absolutePath", cstValidCardInfoVO.getAbsolutePath());
			obj.put("relativePath", cstValidCardInfoVO.getRelativePath());
			result.setData(obj);
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "validateIdCard", "验证未通过! certNo:" + certNo + ", cstNm:" + cstNm, CurrentThreadContext.getCurrentUserName(), ex);
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "validateIdCard", "验证未通过! certNo:" + certNo + ", cstNm:" + cstNm, CurrentThreadContext.getCurrentUserName(), ex);
		}
		return result;
	}
	
	/**
	 * 身份证验证(批量)
	 */
	@RequestMapping(value = "/validateIdCards.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object validateIdCards(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String verify = request.getParameter("verify");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CUST_ID_VALID_SUCC);		
		int count = 0; 
		try {
			if(StringUtils.isNotBlank(verify)){
				String[] vers = verify.split("@");
				if(vers!=null&&vers.length>0){
					for(String ver:vers){
						String[] vs = ver.split(",");
						if(vs!=null&&vs[0].length()>1&&vs[1].length()>1){
							vs[0] = vs[0].substring(0, vs[0].length()-1);
							vs[1] = vs[1].substring(0, vs[1].length()-1);
							vs[2] = vs[2].substring(0, vs[2].length()-1);
							if (StringUtils.isBlank(vs[0]) || vs[0].length() > 20 || !StringUtils.isCustomerName(vs[0])) {
								throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CUST_VALID_CERT_NO_EMPTY+"或者名称格式错误");
							}
							
							if (StringUtils.isBlank(vs[1])) {
								throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CUST_VALID_CERT_NO_EMPTY);
							}
							if(StringUtils.isNotBlank(vs[2])){
								if(vs[2].equals(DictionaryConstant.CODE_CERT_TYP_CD_0)){
									if (!StringUtils.isIdCardNumber(vs[1])) {
										throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CUST_VALID_CERT_NO_ERROR);
									}
									CstValidCardInfoVO cstValidCardInfoVO = this.validCert(vs[0], vs[1], vs[0]+"身份证信息验证未通过!", "validateIdCard");
									if(cstValidCardInfoVO.getSuccess()){
										count++;
									}
								}else{
									count++;
								}
							}
						}else if(vs!=null&&(vs[0].length()>1||vs[1].length()>1)){
							throw new BaseException("请补全客户团队信息");
						}else{
							continue;
						}
					}
				}
			}
			if(count<2){
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "至少录入两条成员信息！");
			}
			/*CstValidCardInfoVO cstValidCardInfoVO = this.validCert(cstNm, certNo, "身份证信息验证未通过!", "validateIdCard");
			JSONObject obj = new JSONObject();
			obj.put("absolutePath", cstValidCardInfoVO.getAbsolutePath());
			obj.put("relativePath", cstValidCardInfoVO.getRelativePath());
			result.setData(obj);*/
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			//BaseLogUtils.info(logger, "validateIdCard", "验证未通过! certNo:" + certNo + ", cstNm:" + cstNm, CurrentThreadContext.getCurrentUserName(), ex);
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			//BaseLogUtils.error(logger, "validateIdCard", "验证未通过! certNo:" + certNo + ", cstNm:" + cstNm, CurrentThreadContext.getCurrentUserName(), ex);
		}
		return result;
	}

	/**
	 * 验证中征码
	 * @param request
	 * @param response
	 * @return
	 * @throws BaseException
	 */
	@RequestMapping(value = "/checkLoanCardNo.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object checkLoanCardNo(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		Long startTm = System.currentTimeMillis();
		BaseLogUtils.info(logger, "checkLoanCardNo", "验证中征码.开始时间：" + startTm + "-请求参数：" + this.getRequestParameter(request));
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "中征码验证成功");
		String loanCardCd = request.getParameter("loanCardCd");
		String id = request.getParameter("id");
		try {
			if(StringUtils.isBlank(loanCardCd)){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo("中征码为空");
			}else{
				boolean flag = this.checkLoanCard(loanCardCd);
				BaseLogUtils.info(logger, "checkLoanCardNo", "验证中征码.格式：" + loanCardCd + "-返回结果：" + flag);
				if(!flag){
					result.setSuccess(BaseConstant.IS_YESNO_NO);
					result.setInfo("中征码格式错误");
				}else{
					//中征码是否重复
					CstCorpBscInfoQueryCondition condition = new CstCorpBscInfoQueryCondition();
					condition.setIsDel(BaseConstant.IS_YESNO_NO);
					condition.setLoanCardCd(loanCardCd);
					List<CstCorpBscInfoVO> cstCorpBscInfoVOList= this.cstBscInfoService.searchCstCorpBscInfoVOListByConditon(condition);
					BaseLogUtils.info(logger, "checkLoanCardNo", "验证中征码.重复验证：" + JSON.toJSONString(cstCorpBscInfoVOList));
					if(CollectionUtils.isNotEmpty(cstCorpBscInfoVOList)){
					    for(CstCorpBscInfoVO cstCorpBscInfoVO : cstCorpBscInfoVOList){
                            if(StringUtils.isNotBlank(id) && id.equals(cstCorpBscInfoVO.getId().toString())){
                                continue;
                            }
                            result.setSuccess(BaseConstant.IS_YESNO_NO);
                            result.setInfo("中征码已存在");
                            break;
                        }
					}
				}
			}
		} catch (Exception e) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("中征码验证异常");
		}
		BaseLogUtils.info(logger, "checkLoanCardNo", "验证中征码.结果：" + JSON.toJSONString(result));
		Long endTm = System.currentTimeMillis();
		BaseLogUtils.info(logger, "checkLoanCardNo", "验证中征码.耗时：" + (endTm - startTm));
		return result;
	}

	/**
	 * 校验中征码格式  16位 由 纯数字或者数字+大写字母组成
	 * @param loanCardCd
	 * @return
	 */
	private boolean checkLoanCard(String loanCardCd) {
		if( Pattern.matches("[A-Z]{16}$",loanCardCd) ){
			return false;
		}else if(!Pattern.matches("[A-Z0-9]{16}$",loanCardCd)){
			return false;
		}else {
			return true;
		}
	}

	/**
	 * 新增自然人时判断是否已经有了,如果有了前台判断是否要带入已有信息
	 */
	@RequestMapping(value = "/getExistNp.do", method = { RequestMethod.GET })
	@ResponseBody
	public Object getExistNp(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		String certNo = request.getParameter("certNo");// 证件号码
		String cstNm = request.getParameter("cstNm");
		String certTypCd = request.getParameter("npCertTypCd");
		try {
			//新增前需要先检查系统是否存在用户信息
			this.checkCstVIDInfoItemNp(request);
			Boolean success = false;
			List<CstBscInfoVO> cstBscInfoVOList = this.cstBscInfoService.checkCstBscInfoNpIsHere(cstNm,certNo,certTypCd, CurrentThreadContext.getCurrentSysCd());
			if(CollectionUtils.isNotEmpty(cstBscInfoVOList)){
				success = true;
			}
			if (!success) {
				result.setSuccess(CustomerConstant.CST_VALID_DATA_IS_NOT_IN_DB);
				result.setInfo(SysLogConstant.LOG_CMM_QUERY_DATA_IS_EMPTY);
				BaseLogUtils.info(logger, "getExistNp", "未获取到数据! certNo:" + certNo + ",cstNm:" + cstNm, CurrentThreadContext.getCurrentUserName());
			}else{
				CstBscInfoVO cstBscInfoVO = cstBscInfoVOList.get(0);
				JSONObject viData = new JSONObject();
				viData.put("cId", cstBscInfoVO.getId());
				viData.put("cstNm", cstBscInfoVO.getCstNm());
				result.setData(viData);
				BaseLogUtils.info(logger, "getExistNp", "获取数据成功! certNo:" + certNo + ",cstNm:" + cstNm, CurrentThreadContext.getCurrentUserName());
			}
		} catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "getExistNp", "操作失败! certNo:" + certNo + ",cstNm:" + cstNm, CurrentThreadContext.getCurrentUserName(), ex);
		} catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "getExistNp", "操作失败! certNo:" + certNo + ",cstNm:" + cstNm, CurrentThreadContext.getCurrentUserName(), ex);
		}
		return result;
	}
	
	/**
	 * 新增法人时判断是否已经有了,如果有了前台判断是否要带入已有信息
	 */
	@RequestMapping(value = "/getExistCorp.do", method = { RequestMethod.GET })
	@ResponseBody
	public Object getExistCorp(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		String cstNm = request.getParameter("cstNm");//名称
		String certNo = request.getParameter("certNo");// 证件号码
		String certTypCd = request.getParameter("certTypCd");//证件类型
		String corpLowerNm = request.getParameter("corpLowerNm");//法人代表名称
		String corpLowerCertNo = request.getParameter("corpLowerCertNo");//法人身份证
		String corpForCertTypCd = request.getParameter("corpForCertTypCd");
		try {
			this.checkCstVIDInfoItemCorp(request);
			if (StringUtils.isBlank(corpLowerNm) || corpLowerNm.length() > 20 || !StringUtils.isCustomerName(corpLowerNm)) {
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CUST_VALID_CORP_LOWER_CST_NM);
			}
			
			if (corpForCertTypCd.equals(DictionaryConstant.CODE_CERT_TYP_CD_0) && !StringUtils.isIdCardNumber(corpLowerCertNo)) {
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CUST_VALID_CERT_NO_ERROR);
			}
			//新增前需要先检查系统是否存在用户信息
			Boolean success = false;
			Boolean isAdd = false;
			CstBscInfoQueryCondition condition = new CstBscInfoQueryCondition();
			condition.setSysCd(CurrentThreadContext.getCurrentSysCd());
			condition.setCstTypCd(CustomerConstant.CST_TYP_CD_CORP);
			condition.setCstNmAll(cstNm);
			List<CstBscInfoVO> csts = null;
			List<CstBscInfoVO> cstList = this.cstBscInfoService.searchListByCon(condition);
			if(CollectionUtils.isNotEmpty(cstList)){
				CstBscInfoQueryCondition cdt = new CstBscInfoQueryCondition();
				cdt.setSysCd(CurrentThreadContext.getCurrentSysCd());
				cdt.setCstTypCd(CustomerConstant.CST_TYP_CD_CORP);
				cdt.setCertNo(certNo);
				cdt.setCertTypCd(certTypCd);
				cdt.setCstNmAll(cstNm);
				csts = this.cstBscInfoService.searchListByCon(cdt);
				if(CollectionUtils.isNotEmpty(csts)){
					success = true;
				}
			}else{
				success = true;
				isAdd = true;
			}
			
			/*List<CstBscInfoVO> cstBscInfoVOList = this.cstBscInfoService.checkCstBscInfoCorpIsHere(cstNm,certNo, certTypCd, CurrentThreadContext.getCurrentSysCd());
			if(CollectionUtils.isNotEmpty(cstBscInfoVOList)){
				success = true;
			}*/
			if(success){
				if(isAdd){
					result.setSuccess(CustomerConstant.CST_VALID_DATA_IS_NOT_IN_DB);
					result.setInfo(SysLogConstant.LOG_CMM_QUERY_DATA_IS_EMPTY);
					BaseLogUtils.info(logger, "getExistCorp", "未获取到数据! certNo:" + certNo, CurrentThreadContext.getCurrentUserName());
				}else{
					CstBscInfoVO cstBscInfoVO = csts.get(0);
					JSONObject viData = new JSONObject();
					viData.put("cId", cstBscInfoVO.getId());
					viData.put("cstNm", cstBscInfoVO.getCstNm());
					result.setData(viData);
					BaseLogUtils.info(logger, "getExistCorp", "获取数据成功! certNo:" + certNo, CurrentThreadContext.getCurrentUserName());
				}
			}else{
				result.setSuccess(CustomerConstant.CST_VALID_DATA_IS_IN_OTHER);
				result.setInfo("已有该用户其他类型数据!");
				BaseLogUtils.info(logger, "getExistCorp", "已有该用户其他类型数据! certTypCd:" + certTypCd, CurrentThreadContext.getCurrentUserName());
			}
		} catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "getExistCorp", "操作失败! certNo:" + certNo, CurrentThreadContext.getCurrentUserName(), ex);
		} catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "getExistCorp", "操作失败! certNo:" + certNo, CurrentThreadContext.getCurrentUserName(), ex);
		}
		return result;
	}
	
	
	/**
	 * 获取客户关系属性列表
	 *//*
	@RequestMapping(value = "/initCstRlTypComboBox.do", method = {RequestMethod.GET})
	@ResponseBody
	public Object initCstRlTypComboBox(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		JSONArray jsonArr = new JSONArray();
		try {
			List<KeyValueVO> empQtyCdList = this.cstBscInfoService.searchCstRlTypList();
			JSONObject jsonObj = new JSONObject();
			if(null != empQtyCdList){
				for (KeyValueVO keyValueVO : empQtyCdList) {
					jsonObj = new JSONObject();
					jsonObj.put("id", keyValueVO.getKey());
					jsonObj.put("text", keyValueVO.getValue());
					jsonArr.add(jsonObj);
				}
			}
		} catch (BaseException ex) {
			BaseLogUtils.info(logger, "initCstRlTypComboBox", "操作失败! , ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		} catch (Exception ex) {
			BaseLogUtils.error(logger, "initCstRlTypComboBox", "操作失败! , ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return jsonArr;
	}*/
	
	/**
	 * 初始化所属行业树
	 */
	@RequestMapping(value = "/initIndCdTree.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object initIndCdTree(HttpServletRequest request, HttpServletResponse response) {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		String pCode = request.getParameter("pCode");
		try {
			if(StringUtils.isEmpty(pCode)){
				pCode = CustomerConstant.CST_DIC_PCODE_INIT_VALUE;
			}
			String dicCode = DictionaryConstant.CODE_GRP_IND_CD;
			JSONArray jsonArray = this.cstBscInfoService.searchTreeByCd(dicCode, pCode);
			BaseLogUtils.info(logger, "initIndCdTree", "初始化所属行业树.",CurrentThreadContext.getCurrentUserName());
			result.setData(jsonArray);
			return jsonArray;
		} catch (Exception e) {
			BaseLogUtils.error(logger, "initIndCdTree", "初始化所属行业树.系统错误！",CurrentThreadContext.getCurrentUserName(), e);
		}
		return new JSONArray();
	}
	
	/**
	 * 初始化所属行业树
	 */
	@RequestMapping(value = "/initStdIndCdTree.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object initStdIndCdTree(HttpServletRequest request, HttpServletResponse response) {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		String pCode = request.getParameter("pCode");
		try {
			if(StringUtils.isEmpty(pCode)){
				pCode = CustomerConstant.CST_DIC_PCODE_INIT_VALUE;
			}
			String dicCode = DictionaryConstant.CODE_GRP_CST_SID_IND_CD;
			JSONArray jsonArray = this.cstBscInfoService.searchTreeByCd(dicCode, pCode);
			BaseLogUtils.info(logger, "initSidIndCdTree", "初始化经济行业树.",CurrentThreadContext.getCurrentUserName());
			result.setData(jsonArray);
			return jsonArray;
		} catch (Exception e) {
			BaseLogUtils.error(logger, "initSidIndCdTree", "初始化经济行业树.系统错误！",CurrentThreadContext.getCurrentUserName(), e);
		}
		return new JSONArray();
	}
	
	/**
	 * 初始化客户逾期列表
	 */
	@RequestMapping(value = "/initCstCreditList.do", method = { RequestMethod.GET })
	@ResponseBody
	public Object initCstCreditList(HttpServletRequest request, HttpServletResponse response) {
		// 查询条件
		String cstId = request.getParameter("cstId");

		CstCreditQC qc = new CstCreditQC();

		List<Long> cstIdList = new ArrayList<>();
		cstIdList.add(Long.valueOf(cstId));
		qc.setCstIdList(cstIdList);

		qc.setPrjStsCd(FlowConstant.FLOW_CHECK_STATE_PASS);
		
		qc.setSysCd(CurrentThreadContext.getFlServiceSysCd());
		List<CstCreditVO> list = new ArrayList<>();
		try {
			list = this.cstBscInfoService.searchCreditList(qc);
		} catch (Exception e) {
			BaseLogUtils.error(logger, "initCstCreditList", "获取数据失败! cstId:" + cstId, CurrentThreadContext.getCurrentUserName(), e);
		}
		ListPageVO<CstCreditVO> listPage = new ListPageVO<CstCreditVO>(list, list.size());
		BaseLogUtils.info(logger, "initCstCreditList", "初始化客户逾期数据.", CurrentThreadContext.getCurrentUserName());
		return listPage;
	}
	
	/**
	 * 检查客户是否有逾期记录
	 */
	@RequestMapping(value = "/checkCstCredit.do", method = { RequestMethod.GET })
	@ResponseBody
	public Object checkCstCredit(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_NO, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		String cstId = request.getParameter("cstId");
		try {
			CstCreditQC qc = new CstCreditQC();
			List<Long> cstIdList = new ArrayList<>();
			cstIdList.add(Long.valueOf(cstId));
			qc.setCstIdList(cstIdList);
			qc.setPrjStsCd(FlowConstant.FLOW_CHECK_STATE_PASS);
			qc.setSysCd(CurrentThreadContext.getFlServiceSysCd());
			List<CstCreditVO> list = this.cstBscInfoService.searchCreditList(qc);
			if(CollectionUtils.isNotEmpty(list)){
				result.setSuccess(BaseConstant.IS_YESNO_YES);
				result.setInfo("有"+list.size()+"条逾期记录!");
				result.setData(list.size());
			}
		} catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "checkCstCredit", "操作失败! cstId:" + cstId, CurrentThreadContext.getCurrentUserName(), ex);
		} catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "checkCstCredit", "操作失败! cstId:" + cstId, CurrentThreadContext.getCurrentUserName(), ex);
		}
		return result;
	}
	
	/**
	 * 验证时间格式（包括长期）
	 */
	@RequestMapping(value = "/checkCertValid.do", method = { RequestMethod.GET })
	@ResponseBody
	public Object checkCertValid(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "验证成功！");
		String certValidSDt = request.getParameter("certValidSDt");
		String certValidEDt = request.getParameter("certValidEDt");
		try {
			if(StringUtils.isNotBlank(certValidSDt)){
				if(!DateUtils.isDate(certValidSDt, "yyyy-MM-dd")){
					result.setSuccess(BaseConstant.IS_YESNO_NO);
					result.setInfo("验证失败，请输入正确证件有效起始日期格式（yyyy-mm-dd）！");
				}
			}
			if(StringUtils.isNotBlank(certValidEDt)){
				if((!DateUtils.isDate(certValidEDt, "yyyy-MM-dd"))
						&&(!certValidEDt.equals(PropertiesCacheUtils.getProperty(SystemConstant.CHECK_DATE_LONG)))){
					result.setSuccess(BaseConstant.IS_YESNO_NO);
					result.setInfo("验证失败，请输入正确证件有效终止日期格式（yyyy-mm-dd 或 长期）！");
				}
			}
			String edate = PropertiesCacheUtils.getProperty(SystemConstant.CHECK_DATE_LONG);
			if(StringUtils.isNotEmpty(certValidEDt) && StringUtils.isNotEmpty(certValidSDt)){
                if (!certValidEDt.equals(PropertiesCacheUtils.getProperty(SystemConstant.CHECK_DATE_LONG))) {
                    Date sDate = DateUtils.formatStringToDate(certValidSDt, "yyyy-MM-dd");
                    Date aDate = DateUtils.formatStringToDate(certValidEDt, "yyyy-MM-dd");
					if (aDate.compareTo(sDate) <= 0) {
						result.setSuccess(BaseConstant.IS_YESNO_NO);
						result.setInfo("验证失败：证件有效止期应大于证件有效起期");
					} else if (aDate.compareTo(new Date()) <= 0) {
						result.setSuccess(BaseConstant.IS_YESNO_NO);
						result.setInfo("验证失败：证件有效止期应大于当前日期");
					} else if (sDate.compareTo(new Date()) > 0) {
						result.setSuccess(BaseConstant.IS_YESNO_NO);
						result.setInfo("验证失败：证件有效起期应小于当前日期");
					}
                }
            }
		} catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("验证失败，请输入正确日期格式（yyyy-mm-dd  或者长期）！");
			BaseLogUtils.info(logger, "checkCertValid", "验证失败!", CurrentThreadContext.getCurrentUserName(), ex);
		} catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("验证失败，请输入正确日期格式（yyyy-mm-dd  或者长期）！");
			BaseLogUtils.error(logger, "checkCertValid", "验证失败!", CurrentThreadContext.getCurrentUserName(), ex);
		}
		return result;
	}

    /***
     *
     *@Description 解除证件绑定
     *@Author shijb
     *@Date 2018/7/4 14:25
     *@Param request 	请求
     *@Param response	响应
     *@return java.lang.Object
     **/
    @RequestMapping(value = "/removeBind.do", method = { RequestMethod.POST })
    @ResponseBody
    public Object removeBind(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		Long staTime = System.currentTimeMillis();
		String certNo = request.getParameter("certNo");//证件号
		BaseLogUtils.info(logger, "removeBind", "解除证件绑定. 参数传入:"+ com.alibaba.fastjson.JSONObject.toJSONString(certNo) , CurrentThreadContext.getCurrentUserName());
    	DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "解绑成功！");

        Long currentUserId = CurrentThreadContext.getCurrentUserId();//当前操作人id
        try {
			result = cstBscInfoService.removeCertBind(certNo,currentUserId);
        } catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("解绑失败");
			BaseLogUtils.info(logger, "removeBind", "解绑失败!", CurrentThreadContext.getCurrentUserName(), ex);
        } catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("解绑失败");
			BaseLogUtils.info(logger, "removeBind", "解绑失败!", CurrentThreadContext.getCurrentUserName(), ex);
        }finally {
            Long endTime = System.currentTimeMillis();
            BaseLogUtils.info(logger, "removeBind", "解除证件绑定.耗时:" + (endTime - staTime) + "毫秒");
		}
        return result;
    }
	
	
	// ********************私有方法********************//
	/**
	 * 获取自然人请求公共参数(新增修改共用)
	 * 
	 * @param request
	 *            请求
	 * @return 自然人客户基本信息
	 */
	private CstBscInfoVO getRequestParamForNp(HttpServletRequest request) throws BaseException {
		// String cstCd = request.getParameter("cstCd");//客户编号
		String cstNm = request.getParameter("cstNm");// 姓名
		String mp1 = request.getParameter("mp1");// 手机号
		String mp2 = request.getParameter("mp2");// 手机号
		String zipNo = request.getParameter("zipNo");//邮编
		String homeTel = request.getParameter("homeTel");//家庭电话
		String certTypCd = DictionaryConstant.CODE_CERT_TYP_CD_0;//TODO 默认自然人证件类型为身份证 request.getParameter("certTypCd");// 证件类型
		String certNo = request.getParameter("certNo");// 证件号码
		if(StringUtils.isNotBlank(request.getParameter("certTypCd"))){
			certTypCd = request.getParameter("certTypCd");
		}
		String rl_certTypCd = DictionaryConstant.CODE_CERT_TYP_CD_0;
		if(StringUtils.isNotBlank(request.getParameter("rl_certTypCd"))){
			rl_certTypCd = request.getParameter("rl_certTypCd");
		}
		String genderCd = request.getParameter("genderCd");// 性别
		String eduLvlCd = request.getParameter("eduLvlCd");// 文化程度
		String indCd = request.getParameter("indCd");// 所属行业
		String workTel = request.getParameter("workTel");//单位电话
		String marStsCd = request.getParameter("marStsCd");// 婚姻状况
		String workPlc = request.getParameter("workPlc");// 工作单位
		String workYrs = request.getParameter("workYrs");// 从业年限
		String birthday = request.getParameter("birthday");// 出生日期
		String idAddr = request.getParameter("idAddr");// 身份证地址
		String homeAddr = request.getParameter("homeAddr");// 家庭地址
		String postAddr = request.getParameter("postAddr");// 通讯地址
		String workAddr = request.getParameter("workAddr");// 单位地址
		String cstRem = request.getParameter("cstRem");// 备注
		// String cstStsCd = request.getParameter("cstStsCd");//客户状态
		String guarTypCd = request.getParameter("guarTypCd");//担保方式
		String guarAmt = request.getParameter("guarAmt");//最高保证金额（元）
		String cstRlTyp = request.getParameter("cstRlTyp");//客户关系属性
		String othIndCd = request.getParameter("othIndCd");//所属其它行业
		String ocpCd = request.getParameter("ocpCd");//职业
		String posCd = request.getParameter("posCd");//职务
		String titCd = request.getParameter("titCd");//职称
		String payTypCd = request.getParameter("payTypCd");//还款方式
		String prjCtrlCd = request.getParameter("prjCtrlCd");//立项控制
		
		String highDgCd = request.getParameter("highDgCd");//最高学历
		String livCndCd = request.getParameter("livCndCd");//居住状况
		String email = request.getParameter("email");//电子邮箱
		String cstLvlCd = request.getParameter("cstLvlCd");//征信客户级别
		String yrInc = request.getParameter("yrInc");//年收入
		String officeZip = request.getParameter("officeZip");//单位地址邮编
		String workStYr = request.getParameter("workStYr");//本单位工作起始年限
		String homeZip = request.getParameter("homeZip");//居住地邮编
		
		String usedNm = request.getParameter("usedNm");//曾用名
		String drvLicTyp = request.getParameter("drvLicTyp");//驾照类型
		String nation = request.getParameter("nation");//民族
		String certValidSDt = request.getParameter("certValidSDt");//证件有效起始日期
		String certValidEDt = request.getParameter("certValidEDt");//证件有效终止日期
		
		// 自然人社会关系
		String rl_rlNm = request.getParameter("rl_rlNm");// 配偶姓名
		//String rl_certTypCd = request.getParameter("rl_certTypCd");// 配偶证件类型
		String rl_certNo = request.getParameter("rl_certNo");// 配偶证件号码
		String rl_mp = request.getParameter("rl_mp");// 配偶手机号
		String rl_workPlc = request.getParameter("rl_workPlc");// 配偶工作单位
		String rl_tel = request.getParameter("rl_tel");// 配偶工作电话
		String rl_idAddr = request.getParameter("rl_idAddr");// 配偶户口所在地-即身份证所在地
		String rl_workAddr = request.getParameter("rl_workAddr");// 配偶单位地址
		String rl_rlRem = request.getParameter("rl_rlRem");// 配偶备注
		String rl_genderCd = request.getParameter("rl_genderCd");
		String rl_birthday = request.getParameter("rl_birthday");//出生日期
		String isSmallBus=request.getParameter("isSmallBusCd");

		// 客户扩展信息
		String ext_schr1 = request.getParameter("ext_schr1");
		String ext_schr2 = request.getParameter("ext_schr2");
		String ext_schr3 = request.getParameter("ext_schr3");
		String ext_schr4 = request.getParameter("ext_schr4");
		String ext_schr5 = request.getParameter("ext_schr5");
		String ext_schr7 = request.getParameter("schr7");

		String ext_mchr1 = request.getParameter("ext_mchr1");
		String ext_mchr2 = request.getParameter("ext_mchr2");
		String ext_mchr3 = request.getParameter("ext_mchr3");
		String ext_mchr4 = request.getParameter("ext_mchr4");
		String ext_mchr5 = request.getParameter("ext_mchr5");
		String ext_mchr6 = request.getParameter("ext_mchr6");
		String ext_mchr7 = request.getParameter("ext_mchr7");
		String ext_mchr8 = request.getParameter("ext_mchr8");

		String ext_bchr1 = request.getParameter("ext_bchr1");
		String ext_bchr2 = request.getParameter("ext_bchr2");

		String ext_num1 = request.getParameter("ext_num1");
		String ext_num2 = request.getParameter("ext_num2");
		String ext_num3 = request.getParameter("ext_num3");
		String ext_num4 = request.getParameter("ext_num4");
		String ext_num5 = request.getParameter("ext_num5");
		String ext_num6 = request.getParameter("ext_num6");
		String ext_num7 = request.getParameter("ext_num7");
		String ext_num8 = request.getParameter("ext_num8");

		String isFarmer = request.getParameter("isFarmer");//是否农户
		
		/*// 验证必填项及长度
		this.checkCstVIDInfoItemNp(request);*/
		
		if(StringUtils.isEmpty(cstRlTyp)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "请选择客户关系!");
		}
		
		if (StringUtils.isEmpty(mp1) || !StringUtils.checkMobileNumber(mp1)) {
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CUST_VALID_MP1);
		}
		
		if (StringUtils.isNotEmpty(mp2) && !StringUtils.checkMobileNumber(mp2)) {
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CUST_VALID_MP2);
		}
		
		if(StringUtils.isNotEmpty(mp1) && StringUtils.isNotEmpty(mp2)){
			if(mp1.equals(mp2)){
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CUST_VALID_MP1_COM_MP2);
			}
		}

		if (StringUtils.isEmpty(certTypCd)) {
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CUST_VALID_CERT_TYP);
		}

		if (StringUtils.isEmpty(birthday) || !DateUtils.isDate(birthday, DateUtils.YYYY_MM_DD)) {
			//用证件号生成
			birthday = StringUtils.getBirthdayByIDCard(certNo);
		}

		if (StringUtils.isEmpty(idAddr)) {
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "户口所在地不能为空!");
		}
		
		/*if (StringUtils.isEmpty(homeAddr)) {
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CUST_VALID_HOME_ADDR);
		}*/
		
		if(StringUtils.isEmpty(postAddr)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "通讯地址不能为空!");
		}
		
		/*if(StringUtils.isEmpty(yrInc)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "请输入年收入!");
		}*/
		
		/*if(StringUtils.isEmpty(homeTel)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "住宅电话不能为空!");
		}*/
		
		/*if(StringUtils.isEmpty(workTel)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "单位电话不能为空!");
		}*/
		String nan = PropertiesCacheUtils.getProperty(fl.constant.facade.framework.constant.DictionaryConstant.CODE_GRP_GENDER_CD_1);
		String nv = PropertiesCacheUtils.getProperty(fl.constant.facade.framework.constant.DictionaryConstant.CODE_GRP_GENDER_CD_2);
		if(StringUtils.isEmpty(genderCd)&&certTypCd.equals(DictionaryConstant.CODE_CERT_TYP_CD_0)){
			//如果是空的就根据身份证号码处理
			genderCd = StringUtils.getGenderCdByIDCard(certNo, nan, nv);
		}
		
		//担保人的时候部分字段非必填项设置：居住地邮编、单位地址邮编、居住状况、本单位工作起始年份、客户分级、最高学历(X)、电子邮箱
		if(cstRlTyp.equals(DictionaryConstant.CODE_GRP_CST_RL_TYP_CD_DBR)){
			//不处理必填	
		}else{//不是担保人的时候要必填设置:居住地邮编、单位地址邮编、居住状况、本单位工作起始年份、客户分级、最高学历(X)、电子邮箱
			/*if(StringUtils.isEmpty(email) || !StringUtils.isEmail(email)){
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "请填写正确的电子邮箱!");
			}*/
			
			//if (StringUtils.isEmpty(highDgCd)) {
				//throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "请选择最高学历!");
			//}
			
			/*if(StringUtils.isEmpty(cstLvlCd)){
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "请选择客户级别!");
			}*/
					
			/*if(StringUtils.isEmpty(workStYr)){
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "请输入本单位工作起始年限(如 2016)!");
			}else{
				if(workStYr.length() != 4){
					workStYr = workStYr.substring(0, 4);
				}
			}*/
			
			/*if (StringUtils.isEmpty(livCndCd)) {
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "请选择居住状况!");
			}*/
					
			/*if(StringUtils.isEmpty(officeZip) || !StringUtils.isPostCode(officeZip)){
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "请输入正确的单位地址邮编!");
			}*/
					
			/*if(StringUtils.isEmpty(homeZip) || !StringUtils.isPostCode(homeZip)){
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "请输入正确的居住地邮编!");
			}*/
		}
		/*
		 * if(StringUtils.isBlank(postAddr)){ throw new
		 * BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604,
		 * "通讯地址不能为空!"); }
		 */

		// 婚姻状况如果是已婚则要判断是否有配偶信息,如果没有则不能新增
		if (StringUtils.isNotEmpty(marStsCd)) {
			if (marStsCd.equals(DictionaryConstant.CODE_GRP_MAR_STS_CD_2)
					|| marStsCd.equals(DictionaryConstant.CODE_GRP_MAR_STS_CD_FIRST)
					|| marStsCd.equals(DictionaryConstant.CODE_GRP_MAR_STS_CD_AGIAN)
					|| marStsCd.equals(DictionaryConstant.CODE_GRP_MAR_STS_CD_BACK)
					) {
				
				if(cstRlTyp.equals(DictionaryConstant.CODE_GRP_CST_RL_TYP_CD_DBR)){
					// 验证配偶信息是否信息完整
					if (StringUtils.isNotEmpty(rl_rlNm) && rl_rlNm.length() > 20 && !StringUtils.isCustomerName(rl_rlNm)) {
						throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604,SysLogConstant.LOG_CUST_VALID_CST_NM);
					}
					if(rl_certTypCd.equals(DictionaryConstant.CODE_CERT_TYP_CD_0)){
						if (StringUtils.isNotEmpty(rl_certNo) && !StringUtils.isIdCardNumber(rl_certNo)) {
							throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CUST_VALID_CERT_NO_ERROR);
						}
						if(StringUtils.isNotEmpty(rl_certNo)){
							rl_genderCd = StringUtils.getGenderCdByIDCard(rl_certNo, nan, nv);
						}
					}
					if (StringUtils.isNotEmpty(rl_mp) && !StringUtils.checkMobileNumber(rl_mp)) {
						throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CMM_VALID_MP);
					}
					if(StringUtils.isEmpty(rl_workPlc)){
						rl_workPlc = "未知";
					}
				}else{
					// 验证配偶信息是否信息完整
					if (StringUtils.isEmpty(rl_rlNm) || rl_rlNm.length() > 20 || !StringUtils.isCustomerName(rl_rlNm)) {
						throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604,SysLogConstant.LOG_CUST_VALID_CST_NM);
					}
					/*if (StringUtils.isEmpty(rl_certTypCd)) {
						throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CUST_VALID_CERT_TYP);
					}*/

					if (StringUtils.isEmpty(rl_certNo)) {
						throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CUST_VALID_CERT_NO_EMPTY);
					}
					if(rl_certTypCd.equals(DictionaryConstant.CODE_CERT_TYP_CD_0)){
						if (!StringUtils.isIdCardNumber(rl_certNo)) {
							throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CUST_VALID_CERT_NO_ERROR);
						}
						if(StringUtils.isNotEmpty(rl_certNo)){
							rl_genderCd = StringUtils.getGenderCdByIDCard(rl_certNo, nan, nv);
						}
					}
					if (StringUtils.isEmpty(rl_mp) || !StringUtils.checkMobileNumber(rl_mp)) {
						throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CMM_VALID_MP);
					}
					
					//rl_genderCd = StringUtils.getGenderCdByIDCard(rl_certNo, nan, nv);

					if (StringUtils.isEmpty(rl_idAddr)) {
						throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CUST_VALID_HK_ADDR);
					}
					
					if(StringUtils.isEmpty(rl_workPlc)){
						rl_workPlc = "未知";
					}
				}
			}
		}
		
		if(StringUtils.isEmpty(workPlc)){
			workPlc = "未知";
			//throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "工作单位不能为空!");
		}
		
		// 动态表单字段处理方式,如果获取到的字段为null说明前端没有显示字段,如果不为null则正常判断逻辑
		if (null != workYrs) {// 动态表单字段
			if (StringUtils.isEmpty(workYrs) || !StringUtils.isNumeric(workYrs)) {
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CUST_VALID_WORK_YRS);
			}
		}

		String buOrgCd = CurrentThreadContext.getCurrentBuOrgCd();
		String orgCd = CurrentThreadContext.getCurrentOrgCd();
		
		// 基本信息
		CstBscInfoVO cstBscInfoVO = new CstBscInfoVO();
		cstBscInfoVO.setCstTypCd(CustomerConstant.CST_TYP_CD_NP);// 默认自然人
		cstBscInfoVO.setCstCd("");
		if(StringUtils.isEmpty(cstLvlCd)){
			cstBscInfoVO.setCstLvlCd(DictionaryConstant.CODE_CST_LVL_CD);// 客户级别
		}else{
			cstBscInfoVO.setCstLvlCd(cstLvlCd);
		}
		cstBscInfoVO.setCstNm(cstNm);
		/*cstBscInfoVO.setMp1(mp1);
		cstBscInfoVO.setMp2(mp2);*/
		cstBscInfoVO.setCertTypCd(certTypCd);
		cstBscInfoVO.setCertNo(certNo);
		cstBscInfoVO.setIndCd(indCd);
		cstBscInfoVO.setOthIndCd(othIndCd);
		//cstBscInfoVO.setCstStsCd(DictionaryConstant.CODE_CST_STS_CD_1);// 默认意向客户
		cstBscInfoVO.setIsDel(BaseConstant.IS_YESNO_NO);
//		cstBscInfoVO.setActMgrId(CurrentThreadContext.getCurrentUserId());
//		cstBscInfoVO.setActMgrNm(CurrentThreadContext.getCurrentUserName());
//		cstBscInfoVO.setActMgrOrgCd(CurrentThreadContext.getCurrentOrgCd());
		cstBscInfoVO.setCstRem(cstRem);
		cstBscInfoVO.setPayTypCd(payTypCd);
		
		cstBscInfoVO.setBuOrgCd(buOrgCd);
		cstBscInfoVO.setOrgCd(orgCd);
		if(StringUtils.isNotEmpty(isFarmer)){
			cstBscInfoVO.setIsFarmer(Integer.valueOf(isFarmer));
		}
		// 自然人
		CstNpBscInfoVO cstNpBscInfoVO = new CstNpBscInfoVO();
		cstNpBscInfoVO.setGenderCd(genderCd);
		cstNpBscInfoVO.setEduLvlCd(eduLvlCd);
		cstNpBscInfoVO.setMarStsCd(marStsCd);
		cstNpBscInfoVO.setWorkPlc(workPlc);
		cstNpBscInfoVO.setMp1(mp1);
		cstNpBscInfoVO.setMp2(mp2);
		cstNpBscInfoVO.setBuOrgCd(buOrgCd);
		cstNpBscInfoVO.setOrgCd(orgCd);
		cstNpBscInfoVO.setZipNo(zipNo);
		cstNpBscInfoVO.setHomeTel(homeTel);
		cstNpBscInfoVO.setWorkTel(workTel);
		cstNpBscInfoVO.setOcpCd(ocpCd);
		cstNpBscInfoVO.setPosCd(posCd);
		cstNpBscInfoVO.setTitCd(titCd);
		cstNpBscInfoVO.setUsedNm(usedNm);
		cstNpBscInfoVO.setDrvLicTyp(drvLicTyp);
		cstNpBscInfoVO.setNation(nation);
		cstNpBscInfoVO.setOfficeZip(officeZip);
		if(StringUtils.isNotEmpty(isSmallBus)){
			cstNpBscInfoVO.setIsSmallBus(Integer.parseInt(isSmallBus));
		}else{
			cstNpBscInfoVO.setIsSmallBus(BaseConstant.IS_YESNO_NO);
		}
		SimpleDateFormat sdfDateFormat = new SimpleDateFormat("yyyy-MM-dd");
		try {
			if(StringUtils.isNotBlank(certValidEDt) && !(certValidEDt.equals(PropertiesCacheUtils.getProperty(SystemConstant.CHECK_DATE_LONG)))){
				certValidEDt = sdfDateFormat.format(sdfDateFormat.parse(certValidEDt));
			}
			if(StringUtils.isNotBlank(certValidSDt)){
				certValidSDt = sdfDateFormat.format(sdfDateFormat.parse(certValidSDt));
			}
		} catch (ParseException e) {
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "时间格式有误！");
		}
		cstNpBscInfoVO.setCertValidEDt(certValidEDt);
		cstNpBscInfoVO.setCertValidSDt(certValidSDt);
		if (StringUtils.isNotEmpty(workYrs)) {// 动态表单字段
			cstNpBscInfoVO.setWorkYrs(Integer.valueOf(workYrs));
		}
		cstNpBscInfoVO.setBirthday(birthday);
		cstNpBscInfoVO.setIdAddr(idAddr);
		cstNpBscInfoVO.setHomeAddr(homeAddr);
		cstNpBscInfoVO.setPostAddr(postAddr);
		if (null != workAddr) {// 动态表单字段
			cstNpBscInfoVO.setWorkAddr(workAddr);
		}
		cstNpBscInfoVO.setIsDel(BaseConstant.IS_YESNO_NO);
		
		cstNpBscInfoVO.setHighDgCd(highDgCd);
		cstNpBscInfoVO.setLivCndCd(livCndCd);
		cstNpBscInfoVO.setEmail(email);
		if(null != yrInc){
			cstNpBscInfoVO.setYrInc(DecimalUtils.convertYuanToFen(Double.valueOf(yrInc)));
		}
		cstNpBscInfoVO.setOfficeZip(officeZip);
		cstNpBscInfoVO.setWorkStYr(workStYr);
		cstNpBscInfoVO.setHomeZip(homeZip);

		// 自然人社会关系
		if (StringUtils.isNotBlank(marStsCd)) {
			if (marStsCd.equals(DictionaryConstant.CODE_GRP_MAR_STS_CD_2)
					|| marStsCd.equals(DictionaryConstant.CODE_GRP_MAR_STS_CD_FIRST)
					|| marStsCd.equals(DictionaryConstant.CODE_GRP_MAR_STS_CD_AGIAN)
					|| marStsCd.equals(DictionaryConstant.CODE_GRP_MAR_STS_CD_BACK)
					) {
				CstNpSocialRlVO cstNpSocialRlVO = new CstNpSocialRlVO();
				cstNpSocialRlVO.setRlNm(rl_rlNm);
				cstNpSocialRlVO.setCertTypCd(rl_certTypCd);
				cstNpSocialRlVO.setCertNo(rl_certNo);
				cstNpSocialRlVO.setMp(rl_mp);
				cstNpSocialRlVO.setWorkPlc(rl_workPlc);
				cstNpSocialRlVO.setTel(rl_tel);
				cstNpSocialRlVO.setIdAddr(rl_idAddr);
				cstNpSocialRlVO.setWorkAddr(rl_workAddr);
				cstNpSocialRlVO.setRlRem(rl_rlRem);
				cstNpSocialRlVO.setIsDel(BaseConstant.IS_YESNO_NO);
				cstNpSocialRlVO.setBuOrgCd(buOrgCd);
				cstNpSocialRlVO.setOrgCd(orgCd);
				cstNpSocialRlVO.setGenderCd(rl_genderCd);
				
				if(rl_certTypCd==DictionaryConstant.CODE_CERT_TYP_CD_0){
					//自动识别生日
					if (!DateUtils.isDate(rl_birthday, DateUtils.YYYY_MM_DD)) {
						//用证件号生成
						rl_birthday = StringUtils.getBirthdayByIDCard(rl_certNo);
					}
					cstNpSocialRlVO.setBirthday(rl_birthday);
				}else{
					if(StringUtils.isNotBlank(rl_certTypCd)){
						cstNpSocialRlVO.setBirthday(rl_birthday);
					}
				}
				
				if(cstRlTyp.equals(DictionaryConstant.CODE_GRP_CST_RL_TYP_CD_DBR)){
					if(StringUtils.isNotEmpty(rl_rlNm) || StringUtils.isNotEmpty(rl_certNo)){
						cstNpBscInfoVO.setCstNpSocialRlVO(cstNpSocialRlVO);
					}
				}else{// 加入客户关系信息
					cstNpBscInfoVO.setCstNpSocialRlVO(cstNpSocialRlVO);
				}
			}
		}
		
		this.setCstBscInfoCstRlTyp(cstRlTyp, cstBscInfoVO, buOrgCd, orgCd, prjCtrlCd);
		
		// 客户扩展信息
		CstExtInfoVO cstExtInfoVO = new CstExtInfoVO();
		cstExtInfoVO.setSchr1(ext_schr1);
		cstExtInfoVO.setSchr2(ext_schr2);
		cstExtInfoVO.setSchr3(ext_schr3);
		cstExtInfoVO.setSchr4(ext_schr4);
		cstExtInfoVO.setSchr5(ext_schr5);
		if(StringUtils.isNotEmpty(guarTypCd)){
			cstExtInfoVO.setSchr6(guarTypCd);
		}else{
			cstExtInfoVO.setSchr6("");
		}
		cstExtInfoVO.setSchr7(ext_schr7);
		cstExtInfoVO.setMchr1(ext_mchr1);
		cstExtInfoVO.setMchr2(ext_mchr2);
		cstExtInfoVO.setMchr3(ext_mchr3);
		cstExtInfoVO.setMchr4(ext_mchr4);
		cstExtInfoVO.setMchr5(ext_mchr5);
		cstExtInfoVO.setMchr6(ext_mchr6);
		cstExtInfoVO.setMchr7(ext_mchr7);
		cstExtInfoVO.setMchr8(ext_mchr8);

		cstExtInfoVO.setBchr1(ext_bchr1);
		cstExtInfoVO.setBchr2(ext_bchr2);
		
		
		if (StringUtils.isBlank(ext_num1) && StringUtils.isNumeric(ext_num1)) {
			cstExtInfoVO.setNum1(Integer.valueOf(ext_num1));
		}

		if (StringUtils.isBlank(ext_num2) && StringUtils.isNumeric(ext_num2)) {
			cstExtInfoVO.setNum2(Integer.valueOf(ext_num2));
		}

		if (StringUtils.isBlank(ext_num3) && StringUtils.isNumeric(ext_num3)) {
			cstExtInfoVO.setNum3(DecimalUtils.convertYuanToFen(Double.valueOf(ext_num3)));
		}

		if (StringUtils.isBlank(ext_num4) && StringUtils.isNumeric(ext_num4)) {
			cstExtInfoVO.setNum4(DecimalUtils.convertYuanToFen(Double.valueOf(ext_num4)));
		}

		if (StringUtils.isBlank(ext_num5) && StringUtils.isNumeric(ext_num5)) {
			cstExtInfoVO.setNum5(DecimalUtils.convertYuanToFen(Double.valueOf(ext_num5)));
		}

		if (StringUtils.isBlank(ext_num6) && StringUtils.isNumeric(ext_num6)) {
			cstExtInfoVO.setNum6(DecimalUtils.convertYuanToFen(Double.valueOf(ext_num6)));
		}

		if (StringUtils.isBlank(ext_num7) && StringUtils.isNumeric(ext_num7)) {
			cstExtInfoVO.setNum7(Integer.valueOf(ext_num7));
		}

		if (StringUtils.isBlank(ext_num8) && StringUtils.isNumeric(ext_num8)) {
			cstExtInfoVO.setNum8(Integer.valueOf(ext_num8));
		}
		
		if(StringUtils.isNotEmpty(guarAmt) && !StringUtils.isUnsignedNumeric(guarAmt)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "请输入正确的最高保证金额");
		}

		if(StringUtils.isNotEmpty(guarAmt)){
			cstExtInfoVO.setNum9(String.valueOf(DecimalUtils.convertYuanToFen(Double.valueOf(guarAmt))));
		}else{
			cstExtInfoVO.setNum9("0");//默认0分
		}

		// 加入客户扩展信息
		cstBscInfoVO.setCstExtInfoVO(cstExtInfoVO);
		// 加入自然人信息
		cstBscInfoVO.setCstNpBscInfoVO(cstNpBscInfoVO);

		return cstBscInfoVO;
	}
	
	//设置随机数据
	private void setRandomDefaultValue(CstBscInfoVO cstBscInfoVO){
		Map<String, List<KeyValueVO>> dicMap = null;
		String highDgCdDic = fl.customer.facade.framework.constant.DictionaryConstant.CODE_GRP_HIGH_DG_CD;
		String eduLvlCdDic = DictionaryConstant.CODE_GRP_EDU_LVL_CD;
		String livCndCdDic = fl.customer.facade.framework.constant.DictionaryConstant.CODE_GRP_LIV_CND_CD;
		String posCdDic = DictionaryConstant.CODE_GRP_CST_POS_CD;
		String cstTitCdDic = DictionaryConstant.CODE_GRP_CST_TIT_CD;
		String ocpCdDic = DictionaryConstant.CODE_GRP_CST_OCP_CD;
		String indCdDic = DictionaryConstant.CODE_GRP_IND_CD;
		try {
			//客户关系属性
			List<String> codeGrpCdList = new ArrayList<>();
			codeGrpCdList.add(highDgCdDic);
			codeGrpCdList.add(eduLvlCdDic);
			codeGrpCdList.add(livCndCdDic);
			codeGrpCdList.add(posCdDic);
			codeGrpCdList.add(cstTitCdDic);
			codeGrpCdList.add(ocpCdDic);
			codeGrpCdList.add(indCdDic);
			dicMap = this.sysDictionaryService.getMultiKvList(CurrentThreadContext.getFlServiceSysCd(), CurrentThreadContext.getCurrentOrgCd(), codeGrpCdList);
		} catch (Exception e) {
			BaseLogUtils.error(logger, "getRequestParamForNp", "获取数据字典错误!" + e.getMessage());
		}finally {
			if(CollectionUtils.isMapEmpty(dicMap)){
				dicMap = new HashMap<>();
			}
		}
		
		CstNpBscInfoVO cstNpBscInfoVO = cstBscInfoVO.getCstNpBscInfoVO();
		String certNo = cstBscInfoVO.getCertNo();
		String zipNo = cstNpBscInfoVO.getZipNo();
		if(StringUtils.isEmpty(cstNpBscInfoVO.getZipNo())){//根据身份证号所属地址系统 生成当地通用邮编
			SysStdRegionQueryCondition sysStdRegionQC = new SysStdRegionQueryCondition();
			List<String> rgnCdList = new ArrayList<>();
			String certNo6 = certNo.substring(0, 6);
			String certNo4 = certNo.substring(0, 4);
			String certNo2 = certNo.substring(0, 2);
			rgnCdList.add(certNo6);
			rgnCdList.add(certNo4+"00");
			rgnCdList.add(certNo2+"0000");
			sysStdRegionQC.setRgnCdList(rgnCdList);
			List<SysStdRegionVO> sysStdRegionVOList = null;
			try {
				sysStdRegionVOList = this.sysStdRegionService.searchStdRegionList(sysStdRegionQC);
			} catch (Exception e) {
				BaseLogUtils.error(logger, "getRequestParamForNp", "获取省市县邮编错误!" + e.getMessage());
			}
			
			if(CollectionUtils.isEmpty(sysStdRegionVOList)){
				zipNo = "000000";
			}else{
				Map<String, String> zipMap = new HashMap<>();
				for (SysStdRegionVO sysStdRegionVO : sysStdRegionVOList) {
					zipMap.put(sysStdRegionVO.getRgnCd(), sysStdRegionVO.getAreaCode());
				}
				
				if(zipMap.containsKey(certNo6)){
					zipNo = zipMap.get(certNo6);
				}else if(zipMap.containsKey(certNo4)){
					zipNo = zipMap.get(certNo4);
				}else if(zipMap.containsKey(certNo2)){
					zipNo = zipMap.get(certNo2);
				}else{
					zipNo = "000000";
				}
			}
			cstNpBscInfoVO.setZipNo(zipNo);
		}
		
		cstNpBscInfoVO.setHomeZip(zipNo);//根据身份证号所属地址系统 生成当地通用邮编
		cstNpBscInfoVO.setOfficeZip(zipNo);//根据身份证号所属地址系统 生成当地通用邮编
		//随机生成
		String highDgCd = cstNpBscInfoVO.getHighDgCd();
		if (StringUtils.isEmpty(highDgCd)) {
			//随机处理
			List<KeyValueVO> list = dicMap.get(highDgCdDic);
			if(CollectionUtils.isNotEmpty(list)){
				Random random = new Random();
				int rd = random.nextInt(list.size());
				highDgCd = list.get(rd).getKey();
				cstNpBscInfoVO.setHighDgCd(highDgCd);
			}
		}
		String eduLvlCd = cstNpBscInfoVO.getEduLvlCd();
		if(StringUtils.isEmpty(eduLvlCd)){
			//随机处理
			List<KeyValueVO> list = dicMap.get(eduLvlCdDic);
			if(CollectionUtils.isNotEmpty(list)){
				Random random = new Random();
				int rd = random.nextInt(list.size());
				eduLvlCd = list.get(rd).getKey();
				cstNpBscInfoVO.setEduLvlCd(eduLvlCd);
			}
		}
		
		String email = cstNpBscInfoVO.getEmail();
		String mp1 = cstNpBscInfoVO.getMp1();
		if(StringUtils.isEmpty(email)){
			email = StringUtils.getRandomMailByphone(mp1);
			//email = mp1+"@163.com";
			cstNpBscInfoVO.setEmail(email);
		}
		String livCndCd = cstNpBscInfoVO.getLivCndCd();
		if(StringUtils.isEmpty(livCndCd)){
			//随机处理
			List<KeyValueVO> list = dicMap.get(livCndCdDic);
			if(CollectionUtils.isNotEmpty(list)){
				Random random = new Random();
				int rd = random.nextInt(list.size());
				livCndCd = list.get(rd).getKey();
				cstNpBscInfoVO.setLivCndCd(livCndCd);
			}
		}
		String posCd = cstNpBscInfoVO.getPosCd();
		if(StringUtils.isEmpty(posCd)){
			//随机处理
			List<KeyValueVO> list = dicMap.get(posCdDic);
			if(CollectionUtils.isNotEmpty(list)){
				Random random = new Random();
				int rd = random.nextInt(list.size());
				posCd = list.get(rd).getKey();
				cstNpBscInfoVO.setPosCd(posCd);
			}
		}
		String titCd = cstNpBscInfoVO.getTitCd();
		if(StringUtils.isEmpty(titCd)){
			//随机处理
			List<KeyValueVO> list = dicMap.get(cstTitCdDic);
			if(CollectionUtils.isNotEmpty(list)){
				Random random = new Random();
				int rd = random.nextInt(list.size());
				titCd = list.get(rd).getKey();
				cstNpBscInfoVO.setTitCd(titCd);
			}
		}
		String ocpCd = cstNpBscInfoVO.getOcpCd();
		if(StringUtils.isEmpty(ocpCd)){
			//重卡事业部：默认“生产、运输设备操作人员及有关人员”。                     
			String zkOrgCd = PropertiesCacheUtils.getProperty(SystemConstant.FL_ZK_BU_ORG_CD);
			if(CurrentThreadContext.getCurrentBuOrgCd().equals(zkOrgCd)){
				String ocpCdDicDefault = PropertiesCacheUtils.getProperty(fl.constant.facade.framework.constant.DictionaryConstant.CODE_GRP_CST_OCP_CD_6);
				ocpCd = ocpCdDicDefault;
			}else{//随机处理
				//其他事业部：在除“国家机关、党群组织、企业、事业单位负责人","办事人员和有关人员","军人","不便分类的其他从业人员"外随机生成
				String gj = PropertiesCacheUtils.getProperty(fl.constant.facade.framework.constant.DictionaryConstant.CODE_GRP_CST_OCP_CD_0);
				String bsry = PropertiesCacheUtils.getProperty(fl.constant.facade.framework.constant.DictionaryConstant.CODE_GRP_CST_OCP_CD_3);
				String jr = PropertiesCacheUtils.getProperty(fl.constant.facade.framework.constant.DictionaryConstant.CODE_GRP_CST_OCP_CD_X);
				String bbfl = PropertiesCacheUtils.getProperty(fl.constant.facade.framework.constant.DictionaryConstant.CODE_GRP_CST_OCP_CD_Y);
				List<KeyValueVO> tempList = dicMap.get(ocpCdDic);
				List<KeyValueVO> list = new ArrayList<>();
				if(CollectionUtils.isNotEmpty(tempList)){
					for (KeyValueVO keyValueVO : tempList) {
						String key = keyValueVO.getKey();
						if(key.equals(gj))continue;
						if(key.equals(bsry))continue;
						if(key.equals(jr))continue;
						if(key.equals(bbfl))continue;
						list.add(keyValueVO);
					}
				}
				
				if(CollectionUtils.isNotEmpty(list)){
					Random random = new Random();
					int rd = random.nextInt(list.size());
					ocpCd = list.get(rd).getKey();
				}
			}
			cstNpBscInfoVO.setOcpCd(ocpCd);
		}
		
		String indCd = cstBscInfoVO.getIndCd();
		if(StringUtils.isEmpty(indCd)){
			//随机处理
			List<KeyValueVO> list = dicMap.get(indCdDic);
			if(CollectionUtils.isNotEmpty(list)){
				Random random = new Random();
				int rd = random.nextInt(list.size());
				indCd = list.get(rd).getKey();
				cstBscInfoVO.setIndCd(indCd);
			}
		}
		
		Long yrInc = cstNpBscInfoVO.getYrInc();
		if(StringUtils.isEmpty(yrInc)){
			 int min=10000;
			 int max=80000;
			 Random random = new Random();
			 int v = random.nextInt(max)%(max-min+1) + min;
			 cstNpBscInfoVO.setYrInc(Long.valueOf(v));
		}
		
		//工作起始年限
		String workStYr = cstNpBscInfoVO.getWorkStYr();
		if(StringUtils.isNotEmpty(workStYr)){
			int currentYearStr = DateUtils.getYear(new Date());
			List<String> yearList = new ArrayList<>();
			int smallYear = 2007;
			//2007 年到当前年
			int length = currentYearStr - smallYear;
			for (int i = 0; i <= length; i++) {
				yearList.add(String.valueOf(smallYear+i));
			}
			
			if(CollectionUtils.isNotEmpty(yearList)){
				Random random = new Random();
				int rd = random.nextInt(yearList.size());
				cstNpBscInfoVO.setWorkStYr(yearList.get(rd));
			}
		}
		String homeTel = cstNpBscInfoVO.getHomeTel();
		if(StringUtils.isEmpty(homeTel)){
			cstNpBscInfoVO.setHomeTel(mp1);
		}
		
		String homeAddr = cstNpBscInfoVO.getHomeAddr();
		if(StringUtils.isEmpty(homeAddr)){
			cstNpBscInfoVO.setHomeAddr(cstNpBscInfoVO.getPostAddr());
		}
		
		String workTel = cstNpBscInfoVO.getWorkTel();
		if(StringUtils.isEmpty(workTel)){
			cstNpBscInfoVO.setWorkTel(mp1);
		}
		
		cstNpBscInfoVO.setWorkAddr(cstNpBscInfoVO.getPostAddr());
	}
	
	public static void main(String[] args) {
		int currentYearStr = DateUtils.getYear(new Date());
		List<String> yearList = new ArrayList<>();
		//2007 年到当前年
		int length = currentYearStr - 2007;
		for (int i = 0; i <= length; i++) {
			yearList.add(String.valueOf(2007+i));
		}
		
	}
	
	/**
	 * 设置客户关系属性
	 * @param cstRlTyp
	 * @param cstBscInfoVO
	 * @param buOrgCd
	 * @param orgCd
	 */
	private void setCstBscInfoCstRlTyp(String cstRlTyp, CstBscInfoVO cstBscInfoVO, String buOrgCd, String orgCd, String prjCtrlCd) {
		//客户关系属性
		String[] cstRlTypArray = cstRlTyp.split(";");
		List<CstRlAttrVO> cstRlAttrList = new ArrayList<>();
		CstRlAttrVO cstRlAttrVO = null;
		Boolean isCst = false;
		for (String crl : cstRlTypArray) {
			cstRlAttrVO = new CstRlAttrVO();
			cstRlAttrVO.setBuOrgCd("");//默认根架构
			cstRlAttrVO.setOrgCd("");//默认根架构
			cstRlAttrVO.setRlTypCd(fl.customer.facade.framework.constant.DictionaryConstant.CODE_GRP_CST_RL_TYP_CD_1);
			cstRlAttrVO.setRlVal(crl);
			cstRlAttrVO.setCstId(null);//后面加入
			//如果是客户则赋值,否则忽略
			if(DictionaryConstant.CODE_GRP_CST_RL_TYP_CD_1.equals(crl)){
				if(StringUtils.isNotEmpty(prjCtrlCd)){
					isCst = true;//不同于空说明选择了立项控制
				}
			}
			cstRlAttrList.add(cstRlAttrVO);
		}
		
		if(isCst){
			cstRlAttrVO = new CstRlAttrVO();
			cstRlAttrVO.setBuOrgCd(buOrgCd);
			cstRlAttrVO.setOrgCd(orgCd);
			cstRlAttrVO.setRlTypCd(fl.customer.facade.framework.constant.DictionaryConstant.CODE_GRP_CST_RL_TYP_CD_2);
			cstRlAttrVO.setCstId(null);//后面加入
			cstRlAttrVO.setRlVal(prjCtrlCd);
			cstRlAttrList.add(cstRlAttrVO);
		}
		
		String cstLvlCd = cstBscInfoVO.getCstLvlCd();
		if(StringUtils.isNotEmpty(cstLvlCd)){
			cstRlAttrVO = new CstRlAttrVO();
			cstRlAttrVO.setBuOrgCd(buOrgCd);
			cstRlAttrVO.setOrgCd(orgCd);
			cstRlAttrVO.setRlTypCd(fl.customer.facade.framework.constant.DictionaryConstant.CODE_GRP_CST_RL_TYP_CD_3);
			cstRlAttrVO.setCstId(null);//后面加入
			cstRlAttrVO.setRlVal(cstLvlCd);
			cstRlAttrList.add(cstRlAttrVO);
		}
		
		if(CollectionUtils.isEmpty(cstRlAttrList)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "请选择客户关系!");
		}
		
		cstBscInfoVO.setCstRlAttrVOList(cstRlAttrList);
	}
	
	/**
	 * 检查重要自然人信息项
	 * @param cstNm
	 * @param certNo
	 */
	private void checkCstVIDInfoItemNp(HttpServletRequest request) {
		
		/*String certTypCd = DictionaryConstant.CODE_CERT_TYP_CD_0;//默认自然人证件类型为身份证
*/		
		String certTypCd = DictionaryConstant.CODE_CERT_TYP_CD_0;
		String certNo = request.getParameter("certNo");// 证件号码
		String cstNm = request.getParameter("cstNm");
		if(StringUtils.isNotBlank(request.getParameter("npCertTypCd"))){
			certTypCd = request.getParameter("npCertTypCd");
		}
		
		// 验证必填项及长度
		if (StringUtils.isBlank(cstNm) || cstNm.length() > 20 || !StringUtils.isCustomerName(cstNm)) {
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604,SysLogConstant.LOG_CUST_VALID_CST_NM);
		}
		
		if (StringUtils.isBlank(certNo)) {
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CUST_VALID_CERT_NO_EMPTY);
		}

		if (certTypCd.equals(DictionaryConstant.CODE_CERT_TYP_CD_0) && !StringUtils.isIdCardNumber(certNo)) {
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CUST_VALID_CERT_NO_ERROR);
		}
	}

	/**
	 * 获取自然人请求参数(新增)
	 * 
	 * @param request
	 *            请求
	 * @return 自然人客户基本信息
	 */
	private CstBscInfoVO getRequestParamForNpAdd(HttpServletRequest request) throws BaseException {
		CstBscInfoVO cstBscInfoVO = this.getRequestParamForNp(request);
		cstBscInfoVO.setCrtTm(new Date());
		cstBscInfoVO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
		cstBscInfoVO.getCstNpBscInfoVO().setCrtTm(new Date());
		cstBscInfoVO.getCstNpBscInfoVO().setCrtUsrId(CurrentThreadContext.getCurrentUserId());
		cstBscInfoVO.setSysCd(CurrentThreadContext.getFlServiceSysCd());
		cstBscInfoVO.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
		cstBscInfoVO.setCstStsCd(DictionaryConstant.CODE_CST_STS_CD_1);// 默认意向客户
		// 客户关系
		CstNpSocialRlVO cstNpSocialRlVO = cstBscInfoVO.getCstNpBscInfoVO().getCstNpSocialRlVO();
		if (null != cstNpSocialRlVO) {
			cstBscInfoVO.getCstNpBscInfoVO().getCstNpSocialRlVO().setCrtTm(new Date());
			cstBscInfoVO.getCstNpBscInfoVO().getCstNpSocialRlVO().setCrtUsrId(CurrentThreadContext.getCurrentUserId());
			cstBscInfoVO.getCstNpBscInfoVO().getCstNpSocialRlVO()
					.setRlTypCd(DictionaryConstant.CODE_GRP_RL_TYP_CD_5);
		}

		// 客户扩展信息
		CstExtInfoVO cstExtInfoVO = cstBscInfoVO.getCstExtInfoVO();
		if (null != cstExtInfoVO) {
			cstBscInfoVO.getCstExtInfoVO().setCrtTm(new Date());
			cstBscInfoVO.getCstExtInfoVO().setCrtUsrId(CurrentThreadContext.getCurrentUserId());
		}
		return cstBscInfoVO;
	}

	/**
	 * 获取自然人请求参数(修改)
	 * 
	 * @param request
	 *            请求
	 * @return 自然人客户基本信息
	 */
	private CstBscInfoVO getRequestParamForNpModify(HttpServletRequest request) throws BaseException {
		String id = request.getParameter("cId");
		if (StringUtils.isBlank(id)) {
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,
					BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		CstBscInfoVO cstBscInfoVO = this.getRequestParamForNp(request);
		cstBscInfoVO.setId(Long.valueOf(id));
		cstBscInfoVO.setMdfTm(new Date());
		cstBscInfoVO.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
		cstBscInfoVO.setSysCd(CurrentThreadContext.getFlServiceSysCd());
		cstBscInfoVO.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
		cstBscInfoVO.getCstNpBscInfoVO().setMdfTm(new Date());
		cstBscInfoVO.getCstNpBscInfoVO().setMdfUsrId(CurrentThreadContext.getCurrentUserId());

		// 客户关系
		CstNpSocialRlVO cstNpSocialRlVO = cstBscInfoVO.getCstNpBscInfoVO().getCstNpSocialRlVO();
		if (null != cstNpSocialRlVO) {
			cstBscInfoVO.getCstNpBscInfoVO().getCstNpSocialRlVO().setCstId(Long.valueOf(id));
			cstBscInfoVO.getCstNpBscInfoVO().getCstNpSocialRlVO().setMdfTm(new Date());
			cstBscInfoVO.getCstNpBscInfoVO().getCstNpSocialRlVO().setMdfUsrId(CurrentThreadContext.getCurrentUserId());
			cstBscInfoVO.getCstNpBscInfoVO().getCstNpSocialRlVO()
					.setRlTypCd(DictionaryConstant.CODE_GRP_RL_TYP_CD_5);
		}
		// 客户扩展信息
		CstExtInfoVO cstExtInfoVO = cstBscInfoVO.getCstExtInfoVO();
		if (null != cstExtInfoVO) {
			cstBscInfoVO.getCstExtInfoVO().setMdfTm(new Date());
			cstBscInfoVO.getCstExtInfoVO().setMdfUsrId(CurrentThreadContext.getCurrentUserId());
		}

		return cstBscInfoVO;
	}

	/**
	 * 获取法人请求公共参数(新增修改共用)
	 * 
	 * @param request
	 *            请求
	 * @return 法人客户基本信息
	 */
	private CstBscInfoVO getRequestParamForCorp(HttpServletRequest request) throws BaseException {
		// String cstCd = request.getParameter("cstCd");//客户编号
		String cstLvlCd = request.getParameter("cstLvlCd");//客户级别
		String certTypCd = request.getParameter("certTypCd");//客户证件类型
		String cstNm = request.getParameter("cstNm");// 企业名称
		String shtNm = request.getParameter("shtNm");//企业名称简称
		//String succ = request.getParameter("succ");//社会统一信用代码
		String corpTax = request.getParameter("corpTax");//企业传真
		String regTel = request.getParameter("regTel");//注册电话
		String lowerCstNm = request.getParameter("lowerCstNm");//法定代表人
		String lowerCertNo = request.getParameter("lowerCertNo");//法定代表人身份证号码
		String bizLicNo = request.getParameter("bizLicNo");// 企业营业执照号
		String corpTypCd = request.getParameter("corpTypCd");// 企业性质
		String regCapAmt = request.getParameter("regCapAmt");// 注册资本
		String regCapUntCd = request.getParameter("regCapUntCd");// 注册资本计量单位
		String regDt = request.getParameter("regDt");// 成立日期
		String expDt = request.getParameter("expDt");// 有效期
		String taxRegNo = request.getParameter("taxRegNo");// 税务登记号
		String paidCapAmt = request.getParameter("paidCapAmt");//实收资本
		String paidCapUntCd = request.getParameter("paidCapUntCd");//实收资本计量单位
		String certNo = request.getParameter("certNo");// 机构代码号
		String bizScope = request.getParameter("bizScope");// 经营范围
		String regAddr = request.getParameter("regAddr");// 注册地址
		String postAddr = request.getParameter("postAddr");// 通讯地址
		String cstRem = request.getParameter("cstRem");// 备注

		String zipNo = request.getParameter("zipNo");//邮编
		String officeAddr = request.getParameter("officeAddr");//公司办公地址
		String othInfo = request.getParameter("othInfo");//其它信息
		
		String officeTel = request.getParameter("officeTel");//办公电话
		String officeArea = request.getParameter("officeArea");//办公用房使用权面积
		String prpAttr = request.getParameter("prpAttr");//房产属性
		String loanCardNo = request.getParameter("loanCardNo");//贷款卡号
		String loanCardPwd = request.getParameter("loanCardPwd");//贷款卡密码
		String loanCardCd = request.getParameter("loanCardCd");//中征码
		String loanAss = request.getParameter("loanAss");//贷款事项约定
		String cstRlTyp = request.getParameter("cstRlTyp");//客户关系属性
		String guarTypCd = request.getParameter("guarTypCd");
		String guarAmt = request.getParameter("guarAmt");
		String othIndCd = request.getParameter("othIndCd");//所属其它行业
		String isInst  = request.getParameter("isInst");//是否事业单位
		String perMitNo = request.getParameter("perMitNo");//开户许可证核准号
		String stdIndCd = request.getParameter("stdIndCd");//经济行业分类
		String regStdProvCd = request.getParameter("regStdProvCd");//省
		String regStdCityCd = request.getParameter("regStdCityCd");//市
		String regStdDistCd = request.getParameter("regStdDistCd");//县
		String payTypCd = request.getParameter("payTypCd");//还款方式
		String prjCtrlCd = request.getParameter("prjCtrlCd");//立项控制
		String prpVal = request.getParameter("prpVal");//房产价值
		
		// String mp = request.getParameter("mp");//手机号码
		// String cstStsCd = request.getParameter("cstStsCd");//客户状态
		// String corpRepBd = request.getParameter("corpRepBd");//法定代表人生日
		// 动态表单信息
		String indCd = request.getParameter("indCd");// 所属行业
		String websit = request.getParameter("websit");// 公司网址
		String empQtyCd = request.getParameter("empQtyCd");//企业规模
		

		// 客户扩展信息
		String ext_schr1 = request.getParameter("ext_schr1");
		String ext_schr2 = request.getParameter("ext_schr2");
		String ext_schr3 = request.getParameter("ext_schr3");
		String ext_schr4 = request.getParameter("ext_schr4");
		String ext_schr5 = request.getParameter("ext_schr5");
		
		String ext_mchr1 = request.getParameter("ext_mchr1");
		String ext_mchr2 = request.getParameter("ext_mchr2");
		String ext_mchr3 = request.getParameter("ext_mchr3");
		String ext_mchr4 = request.getParameter("ext_mchr4");
		String ext_mchr5 = request.getParameter("ext_mchr5");
		String ext_mchr6 = request.getParameter("ext_mchr6");
		String ext_mchr7 = request.getParameter("ext_mchr7");
		String ext_mchr8 = request.getParameter("ext_mchr8");
		String ext_mchr9 = request.getParameter("mchr9");
		
		String ext_bchr1 = request.getParameter("ext_bchr1");
		String ext_bchr2 = request.getParameter("ext_bchr2");

		String ext_num1 = request.getParameter("ext_num1");
		String ext_num2 = request.getParameter("ext_num2");
		String ext_num3 = request.getParameter("ext_num3");
		String ext_num4 = request.getParameter("ext_num4");
		String ext_num5 = request.getParameter("ext_num5");
		String ext_num6 = request.getParameter("ext_num6");
		String ext_num7 = request.getParameter("ext_num7");
		String ext_num8 = request.getParameter("ext_num8");

		// 验证必填项及长度
		this.checkCstVIDInfoItemCorp(request);

		/*
		 * if(StringUtils.isBlank(corpRep) || corpRep.length() > 50){ throw new
		 * BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604,
		 * "法定代表人不能为空,并且长度不能大于20个字符。"); }
		 */

		/*
		 * if(StringUtils.isBlank(cstLvlCd)){ throw new
		 * BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604,
		 * "请选择客户级别!"); }
		 */
		
		if(StringUtils.isEmpty(cstRlTyp)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "请选择客户关系!");
		}

		if (StringUtils.isBlank(corpTypCd)) {
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CUST_VALID_CORP_TYP);
		}

		/*
		 * if(StringUtils.isBlank(bizLicNo)){ throw new
		 * BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604,
		 * "请输入营业执照注册号!"); }
		 */

		if (StringUtils.isBlank(regDt) || !DateUtils.isDate(regDt, DateUtils.YYYY_MM_DD)) {
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CUST_VALID_REG_DT);
		}
		
		if (DateUtils.formatStringToDate(regDt, DateUtils.YYYY_MM_DD).after(new Date())) {
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CUST_VALID_REG_DT_AFTER);
		}

		if (StringUtils.isBlank(expDt) || !DateUtils.isDate(expDt, DateUtils.YYYY_MM_DD)) {
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CUST_VALID_EXP_DT);
		}
		
		if (DateUtils.formatStringToDate(expDt, DateUtils.YYYY_MM_DD).before(new Date())) {
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CUST_VALID_EXP_DT_BEFORE);
		}

		if (StringUtils.isBlank(regCapAmt) || !StringUtils.isUnsignedNumeric(regCapAmt)) {
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CUST_VALID_REG_CAP_AMT);
		}
		
		if (StringUtils.isNotBlank(officeArea) && !StringUtils.isNumeric(officeArea)) {
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CUST_VALID_REG_CAP_AMT);
		}

		/*
		 * if(StringUtils.isBlank(paidCapAmt) ||
		 * !StringUtils.isUnsignedNumeric(paidCapAmt)){ throw new
		 * BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604,
		 * "实收资本不能为空,并且为正数!"); }
		 */

		if (StringUtils.isBlank(regAddr)) {
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CUST_VALID_REG_ADDR);
		}

		if (StringUtils.isBlank(postAddr)) {
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CUST_VALID_POST_ADDR);
		}
		
		
		//税务登记证
		/*if(StringUtils.isNotBlank(taxRegNo)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "税务登记证不能为空!");
		}*/
		//企业传真
		if(StringUtils.isNotBlank(corpTax) && !StringUtils.isNumberAndMiddleLine(corpTax)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CUST_VALID_CORP_TAX);
		}
		/**
		 * 注册电话     tel 或者 phone
		 */
		if(StringUtils.isNotEmpty(regTel) && !StringUtils.isMobilePhoneAndFixedPhone(regTel)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CUST_VALID_REG_TEL);
		}

		// 动态表单信息
		if (null != indCd) {
			if (StringUtils.isBlank(indCd)) {
				//throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CUST_VALID_IND_CD);
			}
		}
		
		if(null != empQtyCd){
			if (StringUtils.isBlank(empQtyCd)) {
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CUST_VALID_EMP_QTY_CD);
			}
		}
		
		if(null != websit){
			if (StringUtils.isNotBlank(websit) && !StringUtils.isUrl(websit)) {
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CUST_VALID_WEBSIT);
			}
		}
		
		if(StringUtils.isEmpty(officeTel) /*&& !StringUtils.isFixedPhone(officeTel)*/){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "办公电话不能为空!");
		}
		
		if(StringUtils.isNotEmpty(loanCardNo) && !StringUtils.isNumeric(loanCardNo)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "贷款卡号格式不正确!");
		}
		
		if(StringUtils.isEmpty(isInst) || !StringUtils.isNumeric(isInst)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "请选择是否是事业单位!");
		}

		if(StringUtils.isEmpty(stdIndCd)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "请选择经济行业分类!");
		}
		
		if(StringUtils.isEmpty(regStdProvCd)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "请选择注册地行政区划-省份!");
		}
		
		if(StringUtils.isEmpty(regStdCityCd)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "请选择注册地行政区划-城市!");
		}
		
		if(StringUtils.isEmpty(regStdDistCd)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "请选择注册地行政区划-区\\县!");
		}
		
		
		//有担保人的时候部分字段必填项设置：营业执照注册号
		if(cstRlTyp.contains(DictionaryConstant.CODE_GRP_CST_RL_TYP_CD_DBR)){
			//营业执照注册号
			if(StringUtils.isBlank(bizLicNo)){
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "营业执照注册号不能为空!");
			}	
		}
				
		
		String buOrgCd = CurrentThreadContext.getCurrentBuOrgCd();
		String orgCd = CurrentThreadContext.getCurrentOrgCd();
		// 基本信息
		CstBscInfoVO cstBscInfoVO = new CstBscInfoVO();
		cstBscInfoVO.setCstTypCd(CustomerConstant.CST_TYP_CD_CORP);// 客户分类-法人
		cstBscInfoVO.setCstCd("");// 客户编号
		if(StringUtils.isEmpty(cstLvlCd)){
			cstBscInfoVO.setCstLvlCd(DictionaryConstant.CODE_CST_LVL_CD);// 客户级别
		}else{
			cstBscInfoVO.setCstLvlCd(cstLvlCd);
		}
		cstBscInfoVO.setCstNm(cstNm);// 客户名称
		//cstBscInfoVO.setMp1("");// 客户手机号
		cstBscInfoVO.setCertTypCd(certTypCd);// 注册证件类型
		cstBscInfoVO.setCertNo(certNo);// 证件号
		//cstBscInfoVO.setCstStsCd(DictionaryConstant.CODE_CST_STS_CD_1);// 客户状态
		cstBscInfoVO.setIsDel(BaseConstant.IS_YESNO_NO);// 未删除
//		cstBscInfoVO.setActMgrId(CurrentThreadContext.getCurrentUserId());// 客户经理ID
//		cstBscInfoVO.setActMgrNm(CurrentThreadContext.getCurrentUserName());// 客户经理名称
//		cstBscInfoVO.setActMgrOrgCd(CurrentThreadContext.getCurrentOrgCd());
		cstBscInfoVO.setCstRem(cstRem);//备注
		// 动态表单项
		cstBscInfoVO.setIndCd(indCd);// 所属行业
		cstBscInfoVO.setOthIndCd(othIndCd);
		cstBscInfoVO.setSysCd(CurrentThreadContext.getCurrentSysCd());
		cstBscInfoVO.setBuOrgCd(CurrentThreadContext.getCurrentBuOrgCd());
		cstBscInfoVO.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
		cstBscInfoVO.setPayTypCd(payTypCd);
		//设置客户关系属性
		this.setCstBscInfoCstRlTyp(cstRlTyp, cstBscInfoVO, buOrgCd, orgCd, prjCtrlCd);

		// 法人基本信息
		CstCorpBscInfoVO cstCorpBscInfoVO = new CstCorpBscInfoVO();
		// cstCorpBscInfoVO.setCorpRep(corpRep);//法定代表人
		/*
		 * if(StringUtils.isNotBlank(corpRepBd)){//法定代表人生日
		 * cstCorpBscInfoVO.setCorpRepBd(DateUtils.formatStringToDate(corpRepBd,
		 * DateUtils.YYYY_MM_DD)); }
		 */
		/*if(certTypCd.equals(CustomerConstant.CST_TYP_CD_CORP_CERT_TYP_ORG)){
			cstCorpBscInfoVO.setSucc(certNo);//组织机构代码证
		}else if(certTypCd.equals(CustomerConstant.CST_TYP_CD_CORP_CERT_TYP_EQU)){
			//社会统一信用代码
		}*/
		cstCorpBscInfoVO.setTaxRegNo(taxRegNo);// 税务登记号
		cstCorpBscInfoVO.setCorpTypCd(corpTypCd);// 企业性质
		cstCorpBscInfoVO.setBizLicNo(bizLicNo);// 营业执照注册号
		cstCorpBscInfoVO.setRegDt(DateUtils.formatStringToDate(regDt, DateUtils.YYYY_MM_DD));// 成立日期
		cstCorpBscInfoVO.setExpDt(DateUtils.formatStringToDate(expDt, DateUtils.YYYY_MM_DD));// 有效期
		cstCorpBscInfoVO.setRegCapAmt(Double.valueOf(regCapAmt));// 注册资本
		cstCorpBscInfoVO.setRegCapUntCd(regCapUntCd);// 计量单位
		if(StringUtils.isNotEmpty(paidCapAmt)){
			cstCorpBscInfoVO.setPaidCapAmt(Double.valueOf(paidCapAmt));//实收资本
			cstCorpBscInfoVO.setPaidCapUntCd(paidCapUntCd);//计量单位
		}
		cstCorpBscInfoVO.setWebsit(websit);// 网址
		cstCorpBscInfoVO.setBizScope(bizScope);// 经营范围
		cstCorpBscInfoVO.setZipNo(zipNo);//通讯地址邮编
		cstCorpBscInfoVO.setOfficeAddr(officeAddr);//办公地址
		cstCorpBscInfoVO.setRegAddr(regAddr);// 注册地址
		cstCorpBscInfoVO.setPostAddr(postAddr);// 通讯地址
		cstCorpBscInfoVO.setOthInfo(othInfo);//其它
		cstCorpBscInfoVO.setIsDel(BaseConstant.IS_YESNO_NO);// 未删除
		cstCorpBscInfoVO.setShtNm(shtNm);//企业简称
		//cstCorpBscInfoVO.setSucc(succ);//社会统一信用代码
		cstCorpBscInfoVO.setCorpTax(corpTax);//企业传真
		cstCorpBscInfoVO.setRegTel(regTel);//注册电话
		cstCorpBscInfoVO.setEmpQtyCd(empQtyCd);//企业规模
		cstCorpBscInfoVO.setOfficeTel(officeTel);
		if(StringUtils.isNotEmpty(officeArea)){
			cstCorpBscInfoVO.setOfficeArea(Integer.valueOf(officeArea));//办公用房使用权面积
		}
		cstCorpBscInfoVO.setPrpAttr(prpAttr);//房产属性
		cstCorpBscInfoVO.setLoanCardNo(loanCardNo);//贷款卡号
		cstCorpBscInfoVO.setLoanCardPwd(loanCardPwd);//贷款卡密码
		cstCorpBscInfoVO.setLoanAss(loanAss);//贷款事项约定
		cstCorpBscInfoVO.setBuOrgCd(buOrgCd);
		cstCorpBscInfoVO.setOrgCd(orgCd);
		if(StringUtils.isNumeric(isInst)){
			cstCorpBscInfoVO.setIsInst(Integer.valueOf(isInst));
		}
		cstCorpBscInfoVO.setPerMitNo(perMitNo);
		cstCorpBscInfoVO.setStdIndCd(stdIndCd);
		cstCorpBscInfoVO.setRegProvCd(regStdProvCd);
		cstCorpBscInfoVO.setRegCityCd(regStdCityCd);
		cstCorpBscInfoVO.setRegDistCd(regStdDistCd);
		cstCorpBscInfoVO.setLoanCardCd(loanCardCd);
		cstCorpBscInfoVO.setPrpVal(prpVal);
		//法人企业团队信息
		CstCorpTeamVO cstCorpTeamVO = new CstCorpTeamVO();
		cstCorpTeamVO.setMTypCd(CustomerConstant.CST_CORP_TEAM_LOWER);//法定代表人
		cstCorpTeamVO.setMNm(lowerCstNm);
		cstCorpTeamVO.setCertTypCd(DictionaryConstant.CODE_CERT_TYP_CD_0);
		cstCorpTeamVO.setCertNo(lowerCertNo);
		cstCorpTeamVO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
		cstCorpTeamVO.setCrtTm(new Date());
		cstCorpTeamVO.setIsDel(BaseConstant.IS_YESNO_NO);
		cstCorpTeamVO.setOrgCd(orgCd);
		cstCorpBscInfoVO.setCstCorpTeamVO(cstCorpTeamVO);
		
		// 客户扩展信息
		CstExtInfoVO cstExtInfoVO = new CstExtInfoVO();
		cstExtInfoVO.setSchr1(ext_schr1);
		cstExtInfoVO.setSchr2(ext_schr2);
		cstExtInfoVO.setSchr3(ext_schr3);
		cstExtInfoVO.setSchr4(ext_schr4);
		cstExtInfoVO.setSchr5(ext_schr5);
		if (StringUtils.isNotEmpty(guarTypCd)) {
			cstExtInfoVO.setSchr6(guarTypCd);
		}

		cstExtInfoVO.setMchr1(ext_mchr1);
		cstExtInfoVO.setMchr2(ext_mchr2);
		cstExtInfoVO.setMchr3(ext_mchr3);
		cstExtInfoVO.setMchr4(ext_mchr4);
		cstExtInfoVO.setMchr5(ext_mchr5);
		cstExtInfoVO.setMchr6(ext_mchr6);
		cstExtInfoVO.setMchr7(ext_mchr7);
		cstExtInfoVO.setMchr8(ext_mchr8);
		cstExtInfoVO.setMchr9(ext_mchr9);
		
		cstExtInfoVO.setBchr1(ext_bchr1);
		cstExtInfoVO.setBchr2(ext_bchr2);

		if (StringUtils.isBlank(ext_num1) && StringUtils.isNumeric(ext_num1)) {
			cstExtInfoVO.setNum1(Integer.valueOf(ext_num1));
		}

		if (StringUtils.isBlank(ext_num2) && StringUtils.isNumeric(ext_num2)) {
			cstExtInfoVO.setNum2(Integer.valueOf(ext_num2));
		}

		if (StringUtils.isBlank(ext_num3) && StringUtils.isNumeric(ext_num3)) {
			cstExtInfoVO.setNum3(DecimalUtils.convertYuanToFen(Double.valueOf(ext_num3)));
		}

		if (StringUtils.isBlank(ext_num4) && StringUtils.isNumeric(ext_num4)) {
			cstExtInfoVO.setNum4(DecimalUtils.convertYuanToFen(Double.valueOf(ext_num4)));
		}

		if (StringUtils.isBlank(ext_num5) && StringUtils.isNumeric(ext_num5)) {
			cstExtInfoVO.setNum5(DecimalUtils.convertYuanToFen(Double.valueOf(ext_num5)));
		}

		if (StringUtils.isBlank(ext_num6) && StringUtils.isNumeric(ext_num6)) {
			cstExtInfoVO.setNum6(DecimalUtils.convertYuanToFen(Double.valueOf(ext_num6)));
		}

		if (StringUtils.isBlank(ext_num7) && StringUtils.isNumeric(ext_num7)) {
			cstExtInfoVO.setNum7(Integer.valueOf(ext_num7));
		}

		if (StringUtils.isBlank(ext_num8) && StringUtils.isNumeric(ext_num8)) {
			cstExtInfoVO.setNum8(Integer.valueOf(ext_num8));
		}
		
		
		if(StringUtils.isNotEmpty(guarAmt) && !StringUtils.isUnsignedNumeric(guarAmt)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "请输入正确的最高保证金额");
		}

		if(StringUtils.isNotEmpty(guarAmt)){
			cstExtInfoVO.setNum9(String.valueOf(DecimalUtils.convertYuanToFen(Double.valueOf(guarAmt))));
		}else{
			cstExtInfoVO.setNum9("0");//默认0分
		}
		// 加入客户扩展信息
		cstBscInfoVO.setCstExtInfoVO(cstExtInfoVO);
		//加入法人基本信息
		cstBscInfoVO.setCstCorpBscInfoVO(cstCorpBscInfoVO);

		return cstBscInfoVO;
	}
	
	/**
	 * 检查重要企业信息项
	 * @param cstNm
	 * @param certNo
	 */
	private void checkCstVIDInfoItemCorp(HttpServletRequest request) {
		
		String cstNm = request.getParameter("cstNm");
		String certNo = request.getParameter("certNo");// 证件号码
		String win_select_customer_type = request.getParameter("win_select_customer_type");//客户类型
		if(CustomerConstant.CST_TYP_CD_NP.equals(win_select_customer_type)){
			if (StringUtils.isBlank(cstNm) || cstNm.length() > 20 || !StringUtils.isCustomerName(cstNm)) {
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CUST_VALID_CST_NM);
			}
		}else if(CustomerConstant.CST_TYP_CD_CORP.equals(win_select_customer_type)){
			if (StringUtils.isBlank(cstNm) || cstNm.length() > 30) {
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "客户名称不能为空!");
			}
		}
		
		if (StringUtils.isBlank(certNo)) {
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, SysLogConstant.LOG_CUST_VALID_CORP_CERT_NO);
		}
		
	}

	/**
	 * 获取法人请求参数(新增)
	 * 
	 * @param request
	 *            请求
	 * @return 法人客户基本信息
	 */
	private CstBscInfoVO getRequestParamForCorpAdd(HttpServletRequest request) throws BaseException {
		CstBscInfoVO cstBscInfoVO = this.getRequestParamForCorp(request);
		cstBscInfoVO.setCstStsCd(DictionaryConstant.CODE_CST_STS_CD_1);// 默认意向客户
		cstBscInfoVO.setCrtTm(new Date());
		cstBscInfoVO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
		cstBscInfoVO.getCstCorpBscInfoVO().setCrtTm(new Date());
		cstBscInfoVO.getCstCorpBscInfoVO().setCrtUsrId(CurrentThreadContext.getCurrentUserId());
		return cstBscInfoVO;
	}

	/**
	 * 获取法人请求参数(修改)
	 * 
	 * @param request
	 *            请求
	 * @return 法人客户基本信息
	 */
	private CstBscInfoVO getRequestParamForCorpModify(HttpServletRequest request) throws BaseException {
		String id = request.getParameter("id");
		if (StringUtils.isBlank(id)) {
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,
					BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		CstBscInfoVO cstBscInfoVO = this.getRequestParamForCorp(request);
		cstBscInfoVO.setId(Long.valueOf(id));
		cstBscInfoVO.setMdfTm(new Date());
		cstBscInfoVO.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
		cstBscInfoVO.getCstCorpBscInfoVO().setMdfTm(new Date());
		cstBscInfoVO.getCstCorpBscInfoVO().setMdfUsrId(CurrentThreadContext.getCurrentUserId());
		return cstBscInfoVO;
	}
	
	/**
	 * 客户默认照片
	 */
	private void getDefaultUserPic(ModelAndView view, String viewName) {
		String serverPath = PropertiesCacheUtils.getProperty(UploadConstant.UPLOAD_SERVER_PATH);//服务地址
		String customerPaht = PropertiesCacheUtils.getProperty(UploadConstant.UPLOAD_COSTOMER_PATH);
		String headPic = PropertiesCacheUtils.getProperty(fl.constant.facade.framework.constant.UploadConstant.DEFAULT_HEAD_PIC);
		view.addObject(viewName, serverPath + customerPaht + headPic);
	}
	
	/**
	 * 到自然人基础变更申请页面
	 * @author JL 20190419
	 */
	@RequestMapping(value = "/toCstNpModApplyPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toCstNpModApplyPage(HttpServletRequest request, HttpServletResponse response) {
		BaseLogUtils.info(logger, "toCstNpModApplyPage", "参数=>"+this.getRequestParameter(request));
		String id = request.getParameter("id");
		String cstNm = request.getParameter("cstNm");
		String certNo = request.getParameter("certNo");
		String npCertTypCd =request.getParameter("npCertTypCd");
		String mySelfImgUrl = request.getParameter("imgUrl");//客户自己身份证照片地址
		
        String modId = request.getParameter("modId"); //变更主表ID（流程业务主键）
        String isFlow = request.getParameter("isFlow"); //流程标识 1：是，0或者空：否
        String isModify = request.getParameter("isModify"); //是否可修改基本信息，1：是，0：否
        String _audStsCd = request.getParameter("_audStsCd"); //客户状态（13：已立项  14：有担保项目） 
        
		ModelAndView view = new ModelAndView("customer/cstbscinfo/custCstNpModAudit");
		view.addObject("cstNm", cstNm);
		view.addObject("certNo", certNo);
		view.addObject("npCertTypCd", npCertTypCd);
		view.addObject("mySelfImgUrl", mySelfImgUrl);
		String serverPath = PropertiesCacheUtils.getProperty(UploadConstant.UPLOAD_SERVER_PATH);//根目录
		view.addObject("mySelfImgUrlAll", serverPath+mySelfImgUrl);
		
		view.addObject("modId", modId); //信息变更主表ID（流程业务主键）
		view.addObject("isFlow", isFlow); //是否流程附加信息页面
        view.addObject("isModify", isModify); //是否可修改（申请、呈报人节点）
        view.addObject("_audStsCd", _audStsCd); //控制页面可编辑字段
		
		if(StringUtils.isEmpty(mySelfImgUrl)){
			//加入默认自然人照片
			this.getDefaultUserPic(view, "mySelfImgUrlAll");
		}
		//加入默认自然人-配偶照片
		this.getDefaultUserPic(view, "myPeiOuImgUrlAll");
		
		try {
			//获取客户ID（针对流程中）
			Long cId = null;
        	if(StringUtils.isNotEmpty(id)){
        		cId = Long.valueOf(id);
        	}else{
        		if(StringUtils.isNotEmpty(modId)){
	        		MfrInfoModVO mfrInfoModVO = this.mfrInfoModService.selectById(Long.valueOf(modId));
	        		if(mfrInfoModVO != null){
	        			cId = mfrInfoModVO.getMfrId();
	        			id = cId.toString();
	        		}
	            	
	                //业务类型 LIST
	                List<String> busTypCdList = new ArrayList<>(2);
	                busTypCdList.add(CustomerConstant.CST_BASE_MOD_FLOW_BUS_TYP_CD);
	                //获取流程发起人组织架构代码
	                SysFlowSHQueryCondition sysFlowSHQueryCondition = new SysFlowSHQueryCondition();
	                sysFlowSHQueryCondition.setDataId(Long.valueOf(modId));
	                sysFlowSHQueryCondition.setBusTypList(busTypCdList);
	                sysFlowSHQueryCondition.setWordsInTheTable(MfrInfoConstant.MFR_INFO_FLOW_S_H_MFR);
	                sysFlowSHQueryCondition.setStatus(BaseConstant.IS_YESNO_YES);
	                sysFlowSHQueryCondition.setSysCd(SplSystemConstant.FL_SYS_CD);
	                List<SysFlowSHDTO> sysFlowSHDTOs = this.flowApiService.searchFlowSHDTOList(sysFlowSHQueryCondition);
	                if(CollectionUtils.isNotEmpty(sysFlowSHDTOs)){
	                    SysFlowSHDTO sysFlowSHDTO = sysFlowSHDTOs.get(0);
	                    view.addObject("currentBuOrgCd", sysFlowSHDTO.getBuOrgCd());
	                }
        		}
        	}
        	view.addObject("id", id);
			
			//客户关系属性
			JSONArray cstRlTypCdJA = this.cstBscInfoService.searchCstRlTypArray();
			view.addObject("cstRlTypCdList", cstRlTypCdJA);
			//新增的时候客户关系属性默认值
			view.addObject("currentCstRlTypeForAdd", DictionaryConstant.CODE_GRP_CST_RL_TYP_CD_1);
			// 证件类型
			List<KeyValueVO> npCertTypCdList = this.cstBscInfoService.searchCertTypCdListZj(CustomerConstant.CST_TYP_CD_NP,CustomerConstant.CST_TYP_CD_NP);
			view.addObject("searchSelectNPCertTypCdList", npCertTypCdList);
			List<String> codeGrpCdList = new ArrayList<>();
			codeGrpCdList.add(DictionaryConstant.CODE_GRP_MAR_STS_CD);
			codeGrpCdList.add(DictionaryConstant.CODE_GRP_GENDER_CD);
			codeGrpCdList.add(fl.customer.facade.framework.constant.DictionaryConstant.CODE_GRP_BACK_PAY_TYP_CD);
			codeGrpCdList.add(fl.customer.facade.framework.constant.DictionaryConstant.CODE_GRP_PRJ_CTRL_CD);
			Map<String, List<KeyValueVO>> dicMap = this.sysDictionaryService.getMultiKvList(CurrentThreadContext.getFlServiceSysCd(), CurrentThreadContext.getCurrentOrgCd(), codeGrpCdList);
			view.addObject("searchSelectMarStsCdList", dicMap.get(DictionaryConstant.CODE_GRP_MAR_STS_CD));// 婚姻状况
			view.addObject("searchSelectGenderCdList", dicMap.get(DictionaryConstant.CODE_GRP_GENDER_CD));// 性别状况
			view.addObject("payTyplist", dicMap.get(fl.customer.facade.framework.constant.DictionaryConstant.CODE_GRP_BACK_PAY_TYP_CD));//还款方式
			view.addObject("prjCtrlCdList", dicMap.get(fl.customer.facade.framework.constant.DictionaryConstant.CODE_GRP_PRJ_CTRL_CD));//立项控制
		} catch (Exception e) {
			BaseLogUtils.error(logger, "toCstNpModApplyPage", "获取基础信息错误!" , e);
		}
		
		BaseLogUtils.info(logger, "toCstNpModApplyPage", "跳转到自然人基础变更申请页面. ID:" + id, CurrentThreadContext.getCurrentUserName());
		return view;
	}
	
	/**
	 * 到法人基础变更申请页面
	 * @author JL 20190419
	 */
	@RequestMapping(value = "/toCstCorpModApplyPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toCstCorpModApplyPage(HttpServletRequest request, HttpServletResponse response) {
		BaseLogUtils.info(logger, "toCstCorpModApplyPage", "参数=>"+this.getRequestParameter(request));
		String id = request.getParameter("id");
		String cstNm = request.getParameter("cstNm");
		String certNo = request.getParameter("certNo");
		String certTypCd = request.getParameter("certTypCd");
		String corpLowerNm = request.getParameter("corpLowerNm");//法人代表名称
		String corpLowerCertNo = request.getParameter("corpLowerCertNo");//法人身份证
		String corpForCertTypCd = request.getParameter("corpForCertTypCd");//法人证件类型
		
        String modId = request.getParameter("modId"); //变更主表ID（流程业务主键）
        String isFlow = request.getParameter("isFlow"); //流程标识 1：是，0或者空：否
        String isModify = request.getParameter("isModify"); //是否可修改基本信息，1：是，0：否
        String _audStsCd = request.getParameter("_audStsCd"); //客户状态（13：已立项  14：有担保项目）
        
		ModelAndView view = new ModelAndView("customer/cstbscinfo/custCstCorpModAudit");
		view.addObject("cstNm", cstNm);
		view.addObject("certNo", certNo);
		view.addObject("certTypCd", certTypCd);
		view.addObject("lowerCstNm", corpLowerNm);
		view.addObject("lowerCertNo", corpLowerCertNo);
		view.addObject("corpForCertTypCd", corpForCertTypCd);
		view.addObject("currentCstRlTypeForAdd", DictionaryConstant.CODE_GRP_CST_RL_TYP_CD_1);//新增的时候客户关系属性默认值
		
		view.addObject("modId", modId); //信息变更主表ID（流程业务主键）
		view.addObject("isFlow", isFlow); //是否流程附加信息页面
        view.addObject("isModify", isModify); //是否可修改（申请、呈报人节点）
        view.addObject("_audStsCd", _audStsCd); //控制页面可编辑字段
        
		// 证件类型
		List<KeyValueVO> certTypCdList = this.cstBscInfoService.searchCertTypCdList(CustomerConstant.CST_TYP_CD_CORP);
		view.addObject("searchSelectCertTypCdList", certTypCdList);
		// 证件类型(自然人)
		List<KeyValueVO> certTypCdForNpList = this.cstBscInfoService.searchCertTypCdList(CustomerConstant.CST_TYP_CD_NP);
		view.addObject("searchSelectCertTypCdForNpList", certTypCdForNpList);
		//客户关系属性
		JSONArray cstRlTypCdJA = this.cstBscInfoService.searchCstRlTypArray();
		view.addObject("cstRlTypCdList", cstRlTypCdJA);
		
		
		try {
			//获取客户ID（针对流程中）
			Long cId = null;
        	if(StringUtils.isNotEmpty(id)){
        		cId = Long.valueOf(id);
        	}else{
        		if(StringUtils.isNotEmpty(modId)){
	        		MfrInfoModVO mfrInfoModVO = this.mfrInfoModService.selectById(Long.valueOf(modId));
	        		if(mfrInfoModVO != null){
	        			cId = mfrInfoModVO.getMfrId();
	        			id = cId.toString();
	        		}
        		}
        	}
        	view.addObject("id", id);
        	
			//主要团队成员
			CstCorpTeamQueryCondition cstCorpTeamQueryCondition = new CstCorpTeamQueryCondition();
			List<Long> cstIdList = new ArrayList<>();
			cstIdList.add(cId); //客户ID
			cstCorpTeamQueryCondition.setCstIdList(cstIdList);
			cstCorpTeamQueryCondition.setSysCd(CurrentThreadContext.getCurrentSysCd());
			List<CstCorpTeamVO> teamMenList = this.cstCorpTeamService.searchList(cstCorpTeamQueryCondition);
			
			cstCorpTeamQueryCondition.setIsDel(2); //流程新增的临时数据
			List<CstCorpTeamVO> teamMenList2 = this.cstCorpTeamService.searchList(cstCorpTeamQueryCondition);
			teamMenList.addAll(teamMenList2);
			
			List<CstCorpTeamVO> teamMenList3 = new ArrayList<>(); //临时变量
			
			//获取变更流程申请修改后的值
			if(StringUtils.isNotEmpty(modId)){
				MfrInfoModDtlQC mfrInfoModDtlQC = new MfrInfoModDtlQC();
				mfrInfoModDtlQC.setModId(Long.valueOf(modId));
				mfrInfoModDtlQC.setIsDel(BaseConstant.IS_YESNO_NO);
				mfrInfoModDtlQC.setIsValid(BaseConstant.IS_YESNO_YES);
				mfrInfoModDtlQC.setTabNm(CustomerConstant.CST_CORP_TEAM_TAB);
				List<MfrInfoModDtlDTO> mfrInfoModDtlDTOS = this.mfrInfoModDtlApiService.searchMfrInfoModDtlDTOList(mfrInfoModDtlQC);
				Map<Long,List<MfrInfoModDtlDTO>> map = new HashMap<>();
				List<Long> ids = new ArrayList<>();
				if(CollectionUtils.isNotEmpty(mfrInfoModDtlDTOS)){
					for (MfrInfoModDtlDTO mfrInfoModDtlDTO: mfrInfoModDtlDTOS) {
						if(CommonOpTypCdEnum.MDF.getOpTypCd().equals(mfrInfoModDtlDTO.getModTypCd())){
							if(map.containsKey(mfrInfoModDtlDTO.getModBusId())){
								map.get(mfrInfoModDtlDTO.getModBusId()).add(mfrInfoModDtlDTO);
							}else{
								List<MfrInfoModDtlDTO> modDtlDTOS = new ArrayList<>();
								modDtlDTOS.add(mfrInfoModDtlDTO);
								map.put(mfrInfoModDtlDTO.getModBusId(),modDtlDTOS);
							}
						}else if(CommonOpTypCdEnum.DEL.getOpTypCd().equals(mfrInfoModDtlDTO.getModTypCd())){
							ids.add(mfrInfoModDtlDTO.getModBusId());
						}
					}
				}
				for (CstCorpTeamVO cstCorpTeamVO: teamMenList) {
					List<MfrInfoModDtlDTO> dtlDTOS = map.get(cstCorpTeamVO.getId());
					if(CollectionUtils.isNotEmpty(dtlDTOS)){
						for (MfrInfoModDtlDTO modDtlDTO:dtlDTOS) {
							Field field = null;
							try {
								field = CstCorpTeamVO.class.getDeclaredField(modDtlDTO.getModAttrFiled());
							} catch (NoSuchFieldException e) {
								e.printStackTrace();
							}
							field.setAccessible(true);
							try {
								field.set((Object) cstCorpTeamVO, modDtlDTO.getModConAft());
							} catch (IllegalAccessException e) {
								e.printStackTrace();
							}
						}
					}
				}
				//将申请时删除的成员去除掉
				if(CollectionUtils.isNotEmpty(ids)){
					boolean addFlag = true;
					Iterator<CstCorpTeamVO> it = teamMenList.iterator();
					while(it.hasNext()){
						addFlag = true;
						CstCorpTeamVO vo = it.next();
						for (Long t_id : ids ) {
							if(t_id.equals(vo.getId())){
								it.remove();
								addFlag = false;
							}
						}
						if(addFlag){
							teamMenList3.add(vo);
						}
					}
					teamMenList = teamMenList3;
				}
	        	
	            //业务类型 LIST
	            List<String> busTypCdList = new ArrayList<>(2);
	            busTypCdList.add(CustomerConstant.CST_BASE_MOD_FLOW_BUS_TYP_CD);
	            //获取流程发起人组织架构代码
	            SysFlowSHQueryCondition sysFlowSHQueryCondition = new SysFlowSHQueryCondition();
	            sysFlowSHQueryCondition.setDataId(Long.valueOf(modId));
	            sysFlowSHQueryCondition.setBusTypList(busTypCdList);
	            sysFlowSHQueryCondition.setWordsInTheTable(MfrInfoConstant.MFR_INFO_FLOW_S_H_MFR);
	            sysFlowSHQueryCondition.setStatus(BaseConstant.IS_YESNO_YES);
	            sysFlowSHQueryCondition.setSysCd(SplSystemConstant.FL_SYS_CD);
	            List<SysFlowSHDTO> sysFlowSHDTOs = this.flowApiService.searchFlowSHDTOList(sysFlowSHQueryCondition);
	            if(CollectionUtils.isNotEmpty(sysFlowSHDTOs)){
	                SysFlowSHDTO sysFlowSHDTO = sysFlowSHDTOs.get(0);
	                view.addObject("currentBuOrgCd", sysFlowSHDTO.getBuOrgCd());
	            }
			}
			view.addObject("teamMenList", teamMenList);
			
			List<String> codeGrpCdList = new ArrayList<>();
			codeGrpCdList.add(DictionaryConstant.CODE_GRP_CORP_TYP_CD);
			codeGrpCdList.add(DictionaryConstant.CODE_GRP_REG_CAP_UNT_CD);
			codeGrpCdList.add(DictionaryConstant.CODE_SYS_YES_NO_CD);
			codeGrpCdList.add(DictionaryConstant.CODE_GRP_M_TYP_CD);
			codeGrpCdList.add(fl.customer.facade.framework.constant.DictionaryConstant.CODE_GRP_BACK_PAY_TYP_CD);
			codeGrpCdList.add(fl.customer.facade.framework.constant.DictionaryConstant.CODE_GRP_PRJ_CTRL_CD);
			Map<String, List<KeyValueVO>> dicMap = this.sysDictionaryService.getMultiKvList(CurrentThreadContext.getFlServiceSysCd(), CurrentThreadContext.getCurrentOrgCd(), codeGrpCdList);
			view.addObject("searchSelectCorpTypCdList", dicMap.get(DictionaryConstant.CODE_GRP_CORP_TYP_CD));//企业性质
			view.addObject("searchSelectRegCapUntCdList", dicMap.get(DictionaryConstant.CODE_GRP_REG_CAP_UNT_CD));//万元 美元
			view.addObject("searchSelectPaidCapUntCdList", dicMap.get(DictionaryConstant.CODE_GRP_REG_CAP_UNT_CD));//万元 美元
			view.addObject("yNList", dicMap.get(DictionaryConstant.CODE_SYS_YES_NO_CD));///是否事业单位
			view.addObject("payTyplist", dicMap.get(fl.customer.facade.framework.constant.DictionaryConstant.CODE_GRP_BACK_PAY_TYP_CD));//还款方式
			view.addObject("prjCtrlCdList", dicMap.get(fl.customer.facade.framework.constant.DictionaryConstant.CODE_GRP_PRJ_CTRL_CD));//立项控制
			view.addObject("searchSelectMTypCdList", dicMap.get(DictionaryConstant.CODE_GRP_M_TYP_CD));
		} catch (Exception e) {
			BaseLogUtils.error(logger, "toCstCorpModApplyPage", "获取基础信息错误!", e);
		}
		BaseLogUtils.info(logger, "toCstCorpModApplyPage", "跳转到法人基础变更申请页面 .ID:" + id, CurrentThreadContext.getCurrentUserName());
		return view;
	}

	/**
	 * 到客户基础变更流程附加信息页面
	 * @author JL 20190419
	 */
	@RequestMapping(value = "/toCstModDetailPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toCstModDetailPage(HttpServletRequest request, HttpServletResponse response) {
		BaseLogUtils.info(logger, "toCstModDetailPage", "参数"+this.getRequestParameter(request));
		String id = request.getParameter("id");
        String modId = request.getParameter("modId"); //变更主表ID（流程业务主键）
        ModelAndView view = null;
        
        try {
        	//获取客户ID（针对流程中）
        	Long cId = null;
        	if(StringUtils.isNotEmpty(id)){
        		cId = Long.valueOf(id);
        	}else{
        		if(StringUtils.isNotEmpty(modId)){
	        		MfrInfoModVO mfrInfoModVO = this.mfrInfoModService.selectById(Long.valueOf(modId));
	        		if(mfrInfoModVO != null){
	        			cId = mfrInfoModVO.getMfrId();
	        			id = cId.toString();
	        			request.setAttribute("id", id);
	        		}
        		}
        	}
        	//获取客户基本信息
        	CstBscInfoVO cstBscInfoVO = this.cstBscInfoService.selectById(cId);
        	if(null != cstBscInfoVO){
        		if("1".equals(cstBscInfoVO.getCstTypCd())){//自然人
        			view = this.toCstNpModApplyPage(request, response);
        		}else{//法人
        			view = this.toCstCorpModApplyPage(request, response);
        		}
        	}else{
        		BaseLogUtils.info(logger, "toCstModDetailPage", "获取客户信息失败！业务主键未获取到！");
                throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_603, BaseExceptionConstant.BASE_EXCEPTION_CODE_603_NAME);
        	}
		} catch (Exception e) {
			BaseLogUtils.error(logger, "toCstModDetailPage", "获取基础信息错误!" , e);
		}
		
		BaseLogUtils.info(logger, "toCstModDetailPage", "跳转到客户基础变更流程附加信息页面. ID:" + id, CurrentThreadContext.getCurrentUserName());
		return view;
	}
	
	/**
	 * 客户主要信息变更流程操作：申请、修改
	 * @author JL 20190419
	 * @param request
	 * @param response
	 * @param cstBscInfoVO
	 * @return
	 */
	public DataResultVO cstModFlowOperate(HttpServletRequest request, HttpServletResponse response, CstBscInfoVO cstBscInfoVO) {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_UPDATE_SUCC);
		//"基础变更"操作
		String modelTyp = CustomerConstant.CST_BASE_MOD_FLOW_BUS_TYP_CD;
//		String procDefKey = request.getParameter("procDefKey");
//		String procDefId = request.getParameter("procDefId");
//		String procNo = request.getParameter("procNo");
		String _modId = request.getParameter("modId"); //变更主表ID
        String isFlow = request.getParameter("isFlow"); //是否流程中
        Long id = cstBscInfoVO.getId();
        
        //判断客户是否发起了流程
        MfrInfoModQC mfrInfoModQC = new MfrInfoModQC();
        List<String> audStsCdList = new ArrayList<String>();
        audStsCdList.add("1"); //审核中
        audStsCdList.add("4"); //驳回呈报人
        mfrInfoModQC.setAudStsCdList(audStsCdList);
        mfrInfoModQC.setMfrId(id); //客户ID
        mfrInfoModQC.setIsNew(BaseConstant.IS_YESNO_YES);
        mfrInfoModQC.setIsDel(BaseConstant.IS_YESNO_NO);
        mfrInfoModQC.setIsValid(BaseConstant.IS_YESNO_YES);
        List<MfrInfoModDTO> mfrInfoModDTOS = this.mfrInfoModApiService.searchMfrInfoModList(mfrInfoModQC);
        if(CollectionUtils.isNotEmpty(mfrInfoModDTOS) && mfrInfoModDTOS.size()>0){
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("基础信息变更流程在审核中，暂不支持修改！");
            result.setId(id);
            return result;
        }
        
        if(StringUtils.isNotEmpty(isFlow) && "1".equals(isFlow)){ //流程中
        	if (StringUtils.isEmpty(_modId)) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
                BaseLogUtils.info(logger, "cstModFlowOperate", "修改客户主要信息,变更主键参数为空！._modId:" + _modId, CurrentThreadContext.getCurrentUserName());
                return result;
            }else{
            	CstBscInfoDTO entity = CstBscInfoVOTransform.toDTO(cstBscInfoVO);
            	entity.setId(Long.valueOf(id));
            	entity.setBuOrgCd(CurrentThreadContext.getCurrentBuOrgCd());
            	boolean success = this.cstBscInfoService.modifyCstBscAgain(entity, _modId);
            	if (!success) {
	            	result.setSuccess(BaseConstant.IS_YESNO_NO);
	            	result.setInfo(SysLogConstant.LOG_CMM_UPDATE_FAIL);
	            	BaseLogUtils.info(logger, "cstModFlowOperate", "主要信息变更-修改客户数据失败.DATA:" + com.alibaba.fastjson.JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
	            	return result;
	            }
            }
        }else{ //发起变更流程
//			if(StringUtils.isNotEmpty(procDefKey)){
				MfrInfoModDTO mfrInfoModDTO = new MfrInfoModDTO();
				mfrInfoModDTO.setIsPayTypMdf(BaseConstant.IS_YESNO_NO); //是否付款方式变更(0:否，1：是)
				mfrInfoModDTO.setIsBscMdf(BaseConstant.IS_YESNO_YES); //是否基础信息变更（0：否，1：是）
				mfrInfoModDTO.setIsFileMdf(BaseConstant.IS_YESNO_NO); //是否附件变更（0：否，1：是）
				mfrInfoModDTO.setIsRlPsnMdf(BaseConstant.IS_YESNO_NO);
				mfrInfoModDTO.setAudStsCd(FlowConstant.FLOW_CHECK_STATE_IN);
				mfrInfoModDTO.setCrtTm(new Date());
				mfrInfoModDTO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
				mfrInfoModDTO.setCrtUsrName(CurrentThreadContext.getCurrentUserName());
				mfrInfoModDTO.setIsDel(BaseConstant.IS_YESNO_NO);
				mfrInfoModDTO.setIsNew(BaseConstant.IS_YESNO_YES);
				mfrInfoModDTO.setIsValid(BaseConstant.IS_YESNO_YES);
				mfrInfoModDTO.setMfrId(Long.valueOf(id));
				mfrInfoModDTO.setTabNm(CustomerConstant.CST_BSC_INFO_TAB); //设置MfrId关联表名
				CstBscInfoDTO cstBscInfoDTO = CstBscInfoVOTransform.toDTO(cstBscInfoVO);
				Long modId = this.cstBscInfoService.addCstInfoMod(mfrInfoModDTO, cstBscInfoDTO);
				if (StringUtils.isEmpty(modId)) {
					result.setSuccess(BaseConstant.IS_YESNO_NO);
					result.setInfo(SysLogConstant.LOG_CMM_UPDATE_FAIL);
					BaseLogUtils.info(logger, "cstModFlowOperate", "基础变更-修改客户信息失败！.DATA:" + com.alibaba.fastjson.JSONObject.toJSONString(mfrInfoModDTO), CurrentThreadContext.getCurrentUserName());
					return result;
				}
				//发起基础变更流程
				FlowStartParamsDTO flowStartParamsDTO = new FlowStartParamsDTO();
				try {
					//流程定义Key和流程定义ID 如果是前端选择的则直接指定,如果不是则系统自动按照配置选择唯一一条记录,如果找不到会提示
					SysFlowManageVQueryCondition flowManaQC = new SysFlowManageVQueryCondition();
					flowManaQC.setSysCd(CurrentThreadContext.getCurrentSysCd());
					flowManaQC.setIsDel(BaseConstant.IS_YESNO_NO);
					flowManaQC.setIsValid(BaseConstant.IS_YESNO_YES);
					flowManaQC.setModelTyp(modelTyp);
					flowManaQC.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
					flowManaQC.setProcDefKey("FLOW_0000_C001_001"); //客户主要信息变更流程
					List<SysFlowManageVDTO> flowManageVListForStart = this.flowApiService.searchFlowManageVListForStart(flowManaQC);
					//查询到唯一流程版本
					if(CollectionUtils.isNotEmpty(flowManageVListForStart) && flowManageVListForStart.size()==1){
						//根据此流程版本发起流程
						SysFlowManageVDTO sysFlowManageVDTO = flowManageVListForStart.get(0);
						flowStartParamsDTO.setProcDefId(sysFlowManageVDTO.getProcDefId()); //流程定义ID(必填)
						flowStartParamsDTO.setProcDefKey(sysFlowManageVDTO.getProcDefKey()); //流程定义标识(必填)
						flowStartParamsDTO.setProcNo(sysFlowManageVDTO.getProcNo()); //流程定义名称(自定义)
					}else{
						result.setSuccess(BaseConstant.IS_YESNO_NO);
						result.setInfo("基础变更流程发起失败,未找到要发起的流程或流程版本不唯一.");
						return result;
					}
					
//					//流程定义标识(必填)
//					flowStartParamsDTO.setProcDefKey(procDefKey);
//					//流程定义ID(必填)
//					flowStartParamsDTO.setProcDefId(procDefId);
//					//流程定义名称(自定义)
//					flowStartParamsDTO.setProcNo(procNo);
					flowStartParamsDTO.setAudStsCd(FlowConstant.FLOW_CHECK_STATE_IN);
					flowStartParamsDTO.setWordsInTheTable(MfrInfoConstant.MFR_INFO_FLOW_S_H_MFR); //动态表名中业务表中字
					flowStartParamsDTO.setBusinessKey(String.valueOf(modId)); //业务数据主键(必填)
					flowStartParamsDTO.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
					flowStartParamsDTO.setBuOrgCd(CurrentThreadContext.getCurrentBuOrgCd());
					flowStartParamsDTO.setSysCd(CurrentThreadContext.getCurrentSysCd());
					flowStartParamsDTO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
					flowStartParamsDTO.setInitiator(String.valueOf(CurrentThreadContext.getCurrentUserId()));
					flowStartParamsDTO.setInitiatorNm(CurrentThreadContext.getCurrentUserName());
					flowStartParamsDTO.setProcPriority(FlowConstant.FLOW_PRIORITY_EMERGENCY);//优先级,可以在界面定义
					//业务类型(必填)-用于区分操作表标识
					flowStartParamsDTO.setBusinessType(MfrInfoConstant.MFR_INFO_MOD_FLOW_S_H_MFR_TAB);//确认用不用
					//模块类型(流程业务分类): 针对直接启动流程的业务使用
					flowStartParamsDTO.setModelTyp(modelTyp);//需要和流程配置中的模块类型匹配
					flowStartParamsDTO.setSearchDesc(CurrentThreadContext.getCurrentOrgDispNm()+"、客户主要信息变更流程大字段参数未定!");
					cmm.mid.core.framework.dto.DataResultDTO dataResultDTO = this.prdMfrInfoService.modifyMfrInfoFlowStart(flowStartParamsDTO);
					if(dataResultDTO != null){
						if(dataResultDTO.getCode() != null && !dataResultDTO.getCode().equals(BaseExceptionConstant.BASE_EXCEPTION_CODE_200)){
							this.prdMfrInfoService.removeMfrInfoMod(modId);
							result.setSuccess(BaseConstant.IS_YESNO_NO);
							result.setInfo(SysLogConstant.LOG_CMM_OPERATE_FAIL);
							BaseLogUtils.info(logger, "cstModFlowOperate", "客户主要信息变更流程发起失败,请求参数：" + com.alibaba.fastjson.JSONObject.toJSONString(flowStartParamsDTO), CurrentThreadContext.getCurrentUserName());
							return result;
						}else {
							result.setData(id);//客户ID
							result.setInfo("主要信息变更流程发起成功！");
							BaseLogUtils.info(logger, "cstModFlowOperate", "客户主要信息变更流程发起成功,请求参数：" + com.alibaba.fastjson.JSONObject.toJSONString(flowStartParamsDTO), CurrentThreadContext.getCurrentUserName());
							return result;
						}
					}
				} catch (BaseException e) {
					result.setSuccess(BaseConstant.IS_YESNO_NO);
					result.setInfo(e.getMessage());
					BaseLogUtils.info(logger, "cstModFlowOperate", "错误[BaseException],请求参数：" + com.alibaba.fastjson.JSONObject.toJSONString(flowStartParamsDTO) + " -ERROR:" +e.getMessage(), CurrentThreadContext.getCurrentUserName());
					e.getStackTrace();
				} catch (Exception e) {
					result.setSuccess(BaseConstant.IS_YESNO_NO);
					result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
					BaseLogUtils.error(logger, "cstModFlowOperate", "错误[Exception],请求参数：" + com.alibaba.fastjson.JSONObject.toJSONString(flowStartParamsDTO) + " -ERROR:" +e.getMessage(), CurrentThreadContext.getCurrentUserName());
					e.getStackTrace();
				}
//			}
        }
        return result;
	}
	
	/**
	 * 主要信息变更流程-获取数据方法
	 * @param request
	 * @return
	 * @throws BaseException
	 */
	@RequestMapping(value = "/getCstInfoFlowById.do", method = { RequestMethod.GET })
	@ResponseBody
	public Object getCstInfoFlowById(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");
        String modId = request.getParameter("modId");
        String currentBuOrgCd = request.getParameter("currentBuOrgCd");
        String isFlow = request.getParameter("isFlow");
        
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		if (StringUtils.isEmpty(id) || StringUtils.isEmpty(modId)) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			return result;
		}
		
		if(StringUtils.isNotEmpty(isFlow) && BaseConstant.IS_YESNO_YES_STR.equals(isFlow)){
			SysFlowSHQueryCondition sysFlowSHQueryCondition = new SysFlowSHQueryCondition();
			sysFlowSHQueryCondition.setWordsInTheTable(MfrInfoConstant.MFR_INFO_FLOW_S_H_MFR);
			sysFlowSHQueryCondition.setStatus(BaseConstant.IS_YESNO_YES);
			sysFlowSHQueryCondition.setDataId(Long.valueOf(id));
			sysFlowSHQueryCondition.setSysCd(CurrentThreadContext.getCurrentSysCd());
			List<SysFlowSHDTO> sysFlowSHDTOS = this.flowApiService.searchFlowSHDTOList(sysFlowSHQueryCondition);
			if(CollectionUtils.isNotEmpty(sysFlowSHDTOS)){
				currentBuOrgCd = sysFlowSHDTOS.get(0).getBuOrgCd();
			}
		}
		
		try {
			//获取变更申请时的客户相关信息
			CstBscInfoVO vo = this.cstBscInfoService.selectCstFlowById(Long.valueOf(id), Long.valueOf(modId), currentBuOrgCd);
			
			if (null == vo) {
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_QUERY_DATA_IS_EMPTY);
				BaseLogUtils.info(logger, "getCstInfoFlowById", "获取数据不存在! ID:" + id, CurrentThreadContext.getCurrentUserName());
			}else{
				BaseLogUtils.info(logger, "getCstInfoFlowById", "获取数据成功! ID:" + id, CurrentThreadContext.getCurrentUserName());
			}
			result.setData(vo);
		} catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "getCstInfoFlowById", "获取数据失败! ID:" + id, CurrentThreadContext.getCurrentUserName(), ex);
		} catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "getCstInfoFlowById", "获取数据失败! ID:" + id, CurrentThreadContext.getCurrentUserName(), ex);
		}
		return result;
	}
	
	/**
	 * 到客户管理-流程跟踪页面
	 */
	@RequestMapping(value = "/toFlowPage.do", method = { RequestMethod.GET})
	public ModelAndView toFlowPage(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView view = new ModelAndView("customer/cstbscinfo/custCstFlowInfoList");
		String sCstId = request.getParameter("sCstId");
		view.addObject("sCstId", sCstId);//设置客户ID值
		BaseLogUtils.info(logger, "toFlowPage", "跳转到客户管理-流程跟踪页面.", CurrentThreadContext.getCurrentUserName());
		return view;
	}
	
	/**
	 * 初始化流程跟踪列表
	 */
	@RequestMapping(value = "/initFlowList.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object initFlowList(HttpServletRequest request, HttpServletResponse response) {
		//获取页面参数
		String sCstId = request.getParameter("sCstId");
		List<Long> dataIdList = new ArrayList<Long>();
		if(StringUtils.isNotEmpty(sCstId)){
			//获取客户变更流程业务主键
			MfrInfoModQC condition = new MfrInfoModQC();
			condition.setMfrId(Long.valueOf(sCstId));
			List<MfrInfoModVO> mfrInfoModVOs = this.mfrInfoModService.searchList(condition);
			if(CollectionUtils.isNotEmpty(mfrInfoModVOs) && mfrInfoModVOs.size()>0){
				for(MfrInfoModVO vo : mfrInfoModVOs){
					if(null != vo.getId()){
						dataIdList.add(vo.getId());
					}
				}
			}
		}
		List<SysFlowSHDTO> flowList = new ArrayList<SysFlowSHDTO>();
		if(CollectionUtils.isNotEmpty(dataIdList)){//业务主键集合不为空
			String sysCd = CurrentThreadContext.getCurrentSysCd();
			String orgCd = CurrentThreadContext.getCurrentOrgCd();
			String codeGrpCd = "SYS0019"; //通用审核状态
			SysFlowSHQueryCondition qc = new SysFlowSHQueryCondition();
			qc.setDataIdList(dataIdList);
			qc.setWordsInTheTable(MfrInfoConstant.MFR_INFO_FLOW_S_H_MFR);
			qc.setBusTyp(CustomerConstant.CST_BASE_MOD_FLOW_BUS_TYP_CD);
			qc.setSysCd(sysCd);
			//查询客户变更历史流程
			flowList = this.flowApiService.searchFlowSHDTOList(qc);
			//查询流程创建人姓名和流程状态中文名
			SysUsrVO usrVo = null;
			SysDictionaryDTO sysDto = null;
			if(CollectionUtils.isNotEmpty(flowList) && flowList.size()>0){
				for(SysFlowSHDTO dto : flowList){
					usrVo = this.sysUsrService.selectById(dto.getCrtUsrId(), sysCd);
					dto.setCrtUsrName(usrVo.getRefRlNm());
					sysDto = sysDictionaryApiService.getCode(sysCd, orgCd, codeGrpCd, dto.getAudStsCd());
					dto.setAudStsCdNm(sysDto.getCodeNm());
				}
			}
		}
		ListPageVO<SysFlowSHDTO> listPage = new ListPageVO<SysFlowSHDTO>(flowList, flowList.size());
		BaseLogUtils.info(logger, "initFlowList", "查询客户变更流程数据完成. DATA:" + com.alibaba.fastjson.JSONObject.toJSONString(listPage), CurrentThreadContext.getCurrentUserName());
		return listPage;
	}
	
	/**
	 * 到变更记录列表页面
	 */
	@RequestMapping(value = "/toModRecListPage.do", method = { RequestMethod.GET})
	public ModelAndView toModRecListPage(HttpServletRequest request, HttpServletResponse response) {
		String modId = request.getParameter("modId");
		String mfrId = request.getParameter("cId"); //客户ID
		Long startTm = System.currentTimeMillis();
		BaseLogUtils.info(logger, "toModRecListPage", "加载列表页面.请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());
		
		ModelAndView view = new ModelAndView("customer/cstbscinfo/custCstModDtlList");
		view.addObject("modId", modId);
		view.addObject("mfrId", mfrId);
		Long endTm = System.currentTimeMillis();
		BaseLogUtils.info(logger, "toModRecListPage", "加载列表页面.耗时：" + (endTm-startTm), CurrentThreadContext.getCurrentUserName());
		return view;
	}
	
	/**
	 * 初始化变更记录列表
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/initModRecList.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object initModRecList(HttpServletRequest request, HttpServletResponse response) {
		Long startTm = System.currentTimeMillis();
		BaseLogUtils.info(logger, "initModRecList", "加载列表页面.请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());

		String currentPage = request.getParameter("page");
		String pageSize = request.getParameter("pagesize");
		String mfrId = request.getParameter("mfrId");

		if (StringUtils.isEmpty(mfrId)) {
			BaseLogUtils.info(logger, "initModRecList", "参数不能为空！mfrId=" + mfrId);
			return null;
		}else{
			List<Long> modIdList = new ArrayList<Long>();
			if(StringUtils.isNotEmpty(mfrId)){
				MfrInfoModQC condition = new MfrInfoModQC();
				condition.setMfrId(Long.valueOf(mfrId));
				condition.setTabNm(CustomerConstant.CST_BSC_INFO_TAB); //设置MfrId关联表名
				List<MfrInfoModVO> mfrInfoModVOs = this.mfrInfoModService.searchList(condition);
				if(CollectionUtils.isNotEmpty(mfrInfoModVOs) && mfrInfoModVOs.size()>0){
					for(MfrInfoModVO vo : mfrInfoModVOs){
						if(null != vo.getId()){
							modIdList.add(vo.getId());
						}
					}
				}
			}
			
			Pager page = new Pager();
			if (StringUtils.isNotEmpty(currentPage)) {
				page.setCurrentPage(Integer.parseInt(currentPage));
			}
			if (StringUtils.isNotEmpty(pageSize)) {
				page.setEveryPage(Integer.parseInt(pageSize));
			}
			List<MfrInfoModDtlVO> list = new ArrayList<MfrInfoModDtlVO>();
			ListPageVO<MfrInfoModDtlVO> listPage = null;
			if(CollectionUtils.isNotEmpty(modIdList) && modIdList.size()>0){
				MfrInfoModDtlQC qc = new MfrInfoModDtlQC();
				qc.setModIdList(modIdList);//变更主表ID集合
				qc.setIsDel(BaseConstant.IS_YESNO_NO);
				page.setCondition(qc);
		
				Pager pager = this.mfrInfoModDtlApiService.searchMfrInfoModDtlListPage(page,CurrentThreadContext.getCurrentSysCd(),CurrentThreadContext.getCurrentOrgCd(),"","");
				list = (List<MfrInfoModDtlVO>) pager.getResultList();
				listPage = new ListPageVO<MfrInfoModDtlVO>(list, pager.getTotalCount());
			}else{
				//返回一个空列表
				listPage = new ListPageVO<MfrInfoModDtlVO>(list, list.size());
			}
			Long endTm = System.currentTimeMillis();
			BaseLogUtils.info(logger, "initModRecList", "加载列表页面.耗时：" + (endTm-startTm), CurrentThreadContext.getCurrentUserName());
			return listPage;
		}
	}
	
	/**
	 * 验证手机三要素真实性
	 */
	@RequestMapping(value = "/checkThreeElements.do", method = { RequestMethod.GET })
	@ResponseBody
	public Object checkThreeElements(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		cmm.mid.core.framework.dto.DataResultDTO result = new cmm.mid.core.framework.dto.DataResultDTO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		String userName = request.getParameter("userName"); //用户名
		String identificationNo = request.getParameter("identificationNo"); //用户证件号
		String mobilePhone = request.getParameter("mobilePhone"); //手机号
		BaseParamDTO baseParam = new BaseParamDTO();
		ApiMobileRealNameValidateDTO mobileRealNameValidate = new ApiMobileRealNameValidateDTO();
		try {
			baseParam.setSysCd(CurrentThreadContext.getCurrentSysCd()); //系统代码
			baseParam.setChannelCd("CHL0001"); //渠道代码：融资租赁后台管理
			baseParam.setServiceCd(CurrentThreadContext.getCurrentSysCd()); //服务代码--暂用
			baseParam.setFrontCd(CurrentThreadContext.getCurrentSysCd()); //前端代码--暂用
			
			mobileRealNameValidate.setUserName(userName);
			mobileRealNameValidate.setIdentificationNo(identificationNo);
			mobileRealNameValidate.setMobilePhone(mobilePhone);
			mobileRealNameValidate.setBussinessTypeCd("CUST"); //业务代码:客户 CUST
			
			//有一个为空就不调用接口校验
			if(StringUtils.isEmpty(userName) || StringUtils.isEmpty(identificationNo) || StringUtils.isEmpty(mobilePhone)){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				BaseLogUtils.info(logger, "checkThreeElements", "手机号三要素：参数不能为空!  =>验证参数:" + com.alibaba.fastjson.JSONObject.toJSONString(mobileRealNameValidate), CurrentThreadContext.getCurrentUserName());
			}
			
			result = this.cfcaUsrApiService.mobileRealNameValidate(mobileRealNameValidate, baseParam);
			if(1 == result.getSuccess()) {
				BaseLogUtils.info(logger, "checkThreeElements", "手机号三要素：验证通过!  =>验证参数:" + com.alibaba.fastjson.JSONObject.toJSONString(mobileRealNameValidate), CurrentThreadContext.getCurrentUserName());
			}else {
				BaseLogUtils.info(logger, "checkThreeElements", "手机号三要素：验证不通过!  =>验证参数:" + com.alibaba.fastjson.JSONObject.toJSONString(mobileRealNameValidate), CurrentThreadContext.getCurrentUserName());
			}
		} catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "checkThreeElements", "验证手机号三要素操作失败! =>验证参数:" + com.alibaba.fastjson.JSONObject.toJSONString(mobileRealNameValidate), CurrentThreadContext.getCurrentUserName(), ex);
		} catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "checkThreeElements", "验证手机号三要素操作失败! =>验证参数:" + com.alibaba.fastjson.JSONObject.toJSONString(mobileRealNameValidate), CurrentThreadContext.getCurrentUserName(), ex);
		}
		return result;
	}
	
	/**
	 * 判断客户是否存在状态为"审核中"的《客户主要信息变更流程》
	 */
	@RequestMapping(value = "/checkCstModFlow.do", method = { RequestMethod.GET })
	@ResponseBody
	public Object checkCstModFlow(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_NO, "无审核中的客户主要信息变更流程，可立项和评审！");
		String cstId = request.getParameter("cstId"); //客户ID
        
		MfrInfoModQC mfrInfoModQC = new MfrInfoModQC();
		try {
			if(StringUtils.isNotEmpty(cstId)){
				List<String> audStsCdList = new ArrayList<String>();
				audStsCdList.add("1"); //审核中
				audStsCdList.add("4"); //驳回呈报人
				mfrInfoModQC.setAudStsCdList(audStsCdList);
				mfrInfoModQC.setMfrId(Long.valueOf(cstId)); //客户ID
				mfrInfoModQC.setIsNew(BaseConstant.IS_YESNO_YES);
				mfrInfoModQC.setIsDel(BaseConstant.IS_YESNO_NO);
				mfrInfoModQC.setIsValid(BaseConstant.IS_YESNO_YES);
				List<MfrInfoModDTO> mfrInfoModDTOS = this.mfrInfoModApiService.searchMfrInfoModList(mfrInfoModQC);
				if(CollectionUtils.isNotEmpty(mfrInfoModDTOS) && mfrInfoModDTOS.size()>0){
					result.setSuccess(BaseConstant.IS_YESNO_YES);
					result.setInfo("客户主要信息变更流程在审核中，暂不支立项和评审！");
				}
				BaseLogUtils.info(logger, "checkCstModFlow", "查询客户主要信息变更流程完成! =>参数:[cstId=" + cstId + "]; mfrInfoModDTOS=" + com.alibaba.fastjson.JSONObject.toJSONString(mfrInfoModDTOS), CurrentThreadContext.getCurrentUserName());
			}else{
				BaseLogUtils.info(logger, "checkCstModFlow", "查询客户主要信息变更流程失败! =>必要参数为空:[cstId=" + cstId + "]", CurrentThreadContext.getCurrentUserName());
			}
		} catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "checkCstModFlow", "查询客户主要信息变更流程错误! =>参数:[cstId=" + cstId + "]; mfrInfoModQC=" + com.alibaba.fastjson.JSONObject.toJSONString(mfrInfoModQC), CurrentThreadContext.getCurrentUserName(), ex);
		} catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "checkCstModFlow", "查询客户主要信息变更流程异常! =>参数:[cstId=" + cstId + "]; mfrInfoModQC=" + com.alibaba.fastjson.JSONObject.toJSONString(mfrInfoModQC), CurrentThreadContext.getCurrentUserName(), ex);
		}
		return result;
	}

	/**
	 * @MethodName checkCstCertNo
	 * @Description: 客户信息修改验证是否进行三要素校验
	 * @Author: wangpengtao@lionbridgecapital.cn
	 * @CreateDate: 2020/3/3 17:35
	 * @Version: V1.0.0
	 * @Param cstBscInfoVO
	 * @Return void
	 * @UpdateRemark [序号][YYYY-MM-DD] [更改人姓名][变更描述]
	 */
	private void checkCstCertNo(CstBscInfoVO cstBscInfoVO) throws BaseException {
        if (null == cstBscInfoVO) {
            throw new BaseException("修改信息不能为空");
        }
        CstBscInfoDTO oldCstBscInfo = cstBscInfoService.selectCstCertNoNm(cstBscInfoVO.getId());
        if (null != oldCstBscInfo) {
            if (StringUtils.isNotEmpty(oldCstBscInfo.getMp1())) {
                if (StringUtils.isNotEmpty(cstBscInfoVO.getCstNm()) || StringUtils.isNotEmpty(cstBscInfoVO.getCertNo())) {
                    boolean cstNmB = !cstBscInfoVO.getCstNm().equals(oldCstBscInfo.getCstNm());
                    boolean certNoB = !cstBscInfoVO.getCertNo().equals(oldCstBscInfo.getCertNo());
                    //姓名或证件号发生变化，进行三要素校验
                    if (cstNmB || certNoB) {
                        boolean checkMp = this.cstBscInfoService.checkMpAndCert(cstBscInfoVO.getCstNm(), cstBscInfoVO.getCertNo(), oldCstBscInfo.getMp1());
                        if (!checkMp) {
                            BaseLogUtils.info(logger, "checkCstCertNo", "手机三要素校验失败");
                            throw new BaseException("客户三要素校验失败");
                        }
                    }
                }
                if(null != cstBscInfoVO.getCstNpBscInfoVO()){
                    cstBscInfoVO.getCstNpBscInfoVO().setMp1(oldCstBscInfo.getMp1());
                }
            }
        }

    }

}
